Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a way to hide the admin menu from subscribers #39

Open
jb510 opened this issue Aug 17, 2016 · 3 comments
Open

Need a way to hide the admin menu from subscribers #39

jb510 opened this issue Aug 17, 2016 · 3 comments

Comments

@jb510
Copy link

jb510 commented Aug 17, 2016

There needs to be an easy way to hide the videos en mass from certain user roles, particularly subscribers on membership/e-commerce sites.

I was assuming this would work, but it doesn't so I must be doing something wrong:

/**
 * Hide WP101 Menu from Subscribers
 */
function s9_wp101_hide_from_subscribers() {
    if ( ! current_user_can( 'edit_posts' ) ) {
        remove_menu_page( 'wp101' );
    }
}
add_action( 'plugins_loaded', 's9_wp101_hide_from_subscribers' );
@billerickson
Copy link

The plugins_loaded hook is too early. That page is added on the admin_menu hook with the default priority (10), so using a later priority should do it for you:

/**
 * Hide WP101 Menu from Subscribers
 */
function s9_wp101_hide_from_subscribers() {
    if ( ! current_user_can( 'edit_posts' ) ) {
        remove_menu_page( 'wp101' );
    }
}
add_action( 'admin_menu', 's9_wp101_hide_from_subscribers', 20 );

@jb510
Copy link
Author

jb510 commented Aug 17, 2016

Doh. Thanks Bill. I actually started with admin_menu, but that didn't work (was missing a later priority) so I blindly moved it to plugins_loaded thinking that was actually later...

the admin_menu, 20 combo is working.

Longer term... I think there ought to be a settings option to hide video from subscribers.

@stevegrunwell
Copy link
Contributor

Within the context of version 5 of the WP101 plugin, the capability used to determine the visibility of the "Video Tutorials" page (defined in WP101\Admin\register_menu_pages()) should be filterable, defaulting to "read".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants