besides init hook, which can I prevent user access to WP dashboard
-
my init function already does something I can’t move/change…
HOWEVER, I need to prevent users from viewing/seeing the WP dashboard.where else can I add the code?
admin_init, that one is only for admin pages OR admin user? If admin user, a user would never fire it anyway? (not sure if that is correct?)If admin_init could work to prevent ‘users’ from seeing the dashboard, that would be great!
also, is this code correct?
if ( is_admin() && !current_user_can( 'administrator' ) && !wp_doing_ajax() ) { wp_redirect( 'my_user_page' ); exit; }
note: what I’m needing to force:
admins — they can see the dashboard.
any other user – they can not see the dashboard and they go to another page.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘besides init hook, which can I prevent user access to WP dashboard’ is closed to new replies.