Help us understand the problem. What is going on with this article?

《Wordpress》Contact Form 7で「Flamingo」の権限をコントロールする。

More than 1 year has passed since last update.

入力フォームプラグイン「Contact Form 7」 を使用している際、データベースに情報を保存してくれるアドオン「flamingo」のいろいろな権限をコントロールする方法です。

以下のコードでは、「flamingo」のあらゆる権限をedit_postsと同等に扱うよう指定しています。

php.function.php
/**
* 
* flamingo custom capability
*
*/
function flamingo_custom_cap( $caps, $cap, $user_id, $args ) {
  $meta_caps = array(
    'flamingo_edit_contacts' => 'edit_posts',
    'flamingo_edit_contact' => 'edit_posts',
    'flamingo_delete_contact' => 'edit_posts',
    'flamingo_edit_inbound_messages' => 'edit_posts',
    'flamingo_delete_inbound_message' => 'edit_posts',
    'flamingo_delete_inbound_messages' => 'edit_posts',
    'flamingo_spam_inbound_message' => 'edit_posts',
    'flamingo_unspam_inbound_message' => 'edit_posts',
    'flamingo_edit_outbound_messages' => 'edit_posts',
    'flamingo_edit_outbound_message' => 'edit_posts',
    'flamingo_delete_outbound_message' => 'edit_posts' );

  $caps = array_diff( $caps, array_keys( $meta_caps ) );

  if ( isset( $meta_caps[$cap] ) )
      $caps[] = $meta_caps[$cap];

  return $caps;
}
remove_filter( 'map_meta_cap', 'flamingo_map_meta_cap' );
add_filter( 'map_meta_cap', 'flamingo_custom_cap', 5, 4 );

edit_postsを任意のものに変更すると、その権限が付与されているユーザーが「flamingo」の閲覧削除などができるようになります。

おわります。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした