• Skip to main content

Julian Thomas Screawn

B.A. ,B.ED. ,M.ED.

  • Home
  • About
  • Computer Upgrades
  • Projects
  • Resources
  • Coding
  • Contact

How to redirect WordPress subscribers to the homepage on login and prevent admin profile access

2023/09/28

add_action( 'init', 'block_subscribers_from_admin' ); 
 function block_subscribers_from_admin() { 
 if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) 
 { wp_redirect( home_url() ); 
 exit; } 
 } 

Filed Under: Wordpress

Copyright © 2023 · Servicing Moncton, Dieppe, Riverview and beyond! · Moncton Meditation · Moncton English Tutor