Reputation: 1262
i have problem with my wordpress admin. when i use account with the role is vendor and go to: mywebsite.com/wp-admin it auto redirect to mywebsite.com, but when i use account is admin1 with the role is work well(direct to mywebsite.com/wp-admin) before it was working well i have deactivated and reactive my plugin and i use function : delete_option('myplugin_default_data_installed'); to remove my plugin when i deactivate my plugin i don't know how to fix it. i know if i remove delete_option() in my plugin it's work well, but know i want to fix in my database any one can help me thank a lot
Upvotes: 0
Views: 77
Reputation: 329
You can do using hooks.put this code in functions.php file.
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && ! current_user_can( 'administrator' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}
I hope this will work for you. Thanks.
Upvotes: 1