Skip to content

WordPress admin menu hook adn user role. check if user role is === 'subscriber' then redirect to dashboard once clicking the plugin menu or hide menu as well

Notifications You must be signed in to change notification settings

nielsoffice/WP_adminMenuUserRole

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

WP_adminMenuUserRole

WordPress admin menu hook and user role. check if user role is === 'subscriber' then redirect to the dashboard once clicking the plugin menu or hide menu as well

// Hide and redirect page once user having no role to access the menu 
 
 admin_menu();
 remove_menu_page();
 remove_menu_sub_page(); 

 //Check user role 
 $user = wp_get_current_user();
 if ( in_array( 'author', (array) $user->roles ) ) {
    //The user has the "author" role
 }


Source :
https://wordpress.stackexchange.com/questions/5047/how-to-check-if-a-user-is-in-a-specific-role

About

WordPress admin menu hook adn user role. check if user role is === 'subscriber' then redirect to dashboard once clicking the plugin menu or hide menu as well

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published