Domanda

I want to give users with user role editor access to my plugin settings page.

.../wp-admin/admin.php?page=myplugin_settingspage

by default only admin can access this page. I implemented this code to protect the config page.

if (!current_user_can('administrator') && !current_user_can('publish_posts')) exit('Admins only.');

But even if I remove this line the page is still protected and for admins only. I guess this protection is done by the WP core. So how to make the page available for users with userrole Editor?

Best Regards

È stato utile?

Soluzione

This looks to be what you need to read:

User Permissions and your Plugin

Not sure how you're attaching your plugins setting page at the moment, but when you do it like so:

add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );

You get to set the capability the user needs to see it.

Hope that helps!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top