WordPress.org

Ready to get started?Download WordPress

Forums

Flamingo
[resolved] Using the flamingo_map_meta_cap filter (4 posts)

  1. wilirius
    Member
    Posted 7 months ago #

    I am attempting to allow editors to see the Flamingo posts. I have tried putting the following into a plugin:

    $fl_meta_caps = array(
        'flamingo_edit_contacts' => 'delete_page',
        'flamingo_edit_contact' => 'delete_page',
        'flamingo_delete_contact' => 'delete_page',
        'flamingo_edit_inbound_messages' => 'delete_page',
        'flamingo_delete_inbound_message' => 'delete_page',
        'flamingo_delete_inbound_messages' => 'delete_page',
        'flamingo_spam_inbound_message' => 'delete_page',
        'flamingo_unspam_inbound_message' => 'delete_page' );
    
    add_filter('flamingo_map_meta_cap', $fl_meta_caps);

    and it ends up giving the editor rights to admin-level capabilities.

    I have seen the example for specific users., but I would like to allow all editors this ability, but not authors.

    http://wordpress.org/plugins/flamingo/

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 7 months ago #

    You are incorrectly using add_filter(). See http://codex.wordpress.org/Function_Reference/add_filter

  3. wilirius
    Member
    Posted 7 months ago #

    I had actually tried returning it via a function, but when that didn't work I tried a couple more things. It is either the filters or map_meta_cap that I do not understand.

    It appears that the filter only needs an array returned, but I must be wrong.

    This function simply removes flamingo from all users capabilities.

    function fl_map_meta_cap($meta_caps){
    	$meta_caps = array(
    		'flamingo_edit_contacts' => 'delete_page',
    		'flamingo_edit_contact' => 'delete_page',
    		'flamingo_delete_contact' => 'delete_page',
    		'flamingo_edit_inbound_messages' => 'delete_page',
    		'flamingo_delete_inbound_message' => 'delete_page',
    		'flamingo_delete_inbound_messages' => 'delete_page',
    		'flamingo_spam_inbound_message' => 'delete_page',
    		'flamingo_unspam_inbound_message' => 'delete_page');
    
    	return $meta_caps;
    }
    add_filter('flamingo_map_meta_cap', 'fl_map_meta_cap');
  4. wilirius
    Member
    Posted 7 months ago #

    Resolved. I needed to change 'delete_page' to 'delete_pages'

    function fl_map_meta_cap($meta_caps){
    	$meta_caps = array(
    		'flamingo_edit_contacts' => 'delete_pages',
    		'flamingo_edit_contact' => 'delete_pages',
    		'flamingo_delete_contact' => 'delete_pages',
    		'flamingo_edit_inbound_messages' => 'delete_pages',
    		'flamingo_delete_inbound_message' => 'delete_pages',
    		'flamingo_delete_inbound_messages' => 'delete_pages',
    		'flamingo_spam_inbound_message' => 'delete_pages',
    		'flamingo_unspam_inbound_message' => 'delete_pages');
    
    	return $meta_caps;
    }
    add_filter('flamingo_map_meta_cap', 'fl_map_meta_cap');

    Thank you Takayuki Miyoshi.

Reply

You must log in to post.

About this Plugin

About this Topic