Hi @eric3d that feature is on my list of things to do but i’ll be honest with you it’s pretty low on the list. I’ve had less than 10 people ask for that.
Thread Starter
eric3d
(@eric3d)
Thanks. This seems to work. Around line 75:
add_action( 'plugins_loaded', 'set_simple_banner_cap' );
function set_simple_banner_cap(){
$admin = get_role( 'administrator' );
$admin->add_cap( 'manage_simple_banner' );
}
add_action('admin_menu', 'simple_banner_menu');
function simple_banner_menu() {
add_menu_page('Simple Banner Settings', 'Simple Banner', 'manage_simple_banner', 'simple-banner-settings', 'simple_banner_settings_page', 'dashicons-admin-generic');
}
This creates a new capability ‘manage_simple_banner’ and grants that capability to admins, then it checks for that capability (instead of role) to display the edit page.
I can then grant that capability to any user (with a plugin like User Role Editor) and they can access the page. The only issue is that I also need to grant manage_options permissions so the user can save the banner.
Thanks, i’ll look into this.
I’d really like this feature too – I’m surprised it isn’t more requested.
I tried the code snippet but I got a PHP error although I don’t see any obvious syntax problems. Any suggestions @eric3d ?
I was able to get this working with the following code in my functions.php:
remove_action('admin_menu', 'simple_banner_menu');
add_action('admin_menu', 'new_simple_banner_menu');
function new_simple_banner_menu() {
add_menu_page('Simple Banner Settings', 'Simple Banner', 'editor', 'simple-banner-settings', 'simple_banner_settings_page', 'dashicons-admin-generic');
}
Thread Starter
eric3d
(@eric3d)
@cbsteven Are you able to save the banner as an editor with this, or do you still have to grant permissions to manage_options? Displaying the settings page is one step, saving the settings is another.
@eric3d Yes my code snippet above allows an Editor user to edit settings and save a new banner, tested on the life site. No granting of permissions beyond assigning Editor to a user.
Your snippet would probably work in functions.php too but I think it would require the remove_action() call first.
Hi @cbsteven @eric3d
The most recent update, 2.3.0, has permissions adding. Let me know if that works or doesn’t work for you. Thanks.