Redirect non admin users to home page and disallow back end access in wordpress

 In Web Design

Redirect non admin users to home page and disallow back end access in WordPress

For Redirect non admin users to home page and disallow back end access in WordPress you need to simply copy and paste the following code in your theme’s functions.php file.

follow the below steps of code:

 

function redirect_non_admin_user(){
if ( !defined( ‘DOING_AJAX’ ) && !current_user_can(‘administrator’) ){
wp_redirect( site_url() );  exit;
}
}
add_action( ‘admin_init’, ‘redirect_non_admin_user’ );

Recent Posts

Leave a Comment

one × five =

Start typing and press Enter to search

Disable WooCommerce Payment methods based on cart item quantityDynamic Web Design Company