Skip to content

Instantly share code, notes, and snippets.

@1naveengiri
Last active December 13, 2023 15:33
Show Gist options
  • Save 1naveengiri/53620b82fbbb5aef7f060cac2616eff4 to your computer and use it in GitHub Desktop.
Save 1naveengiri/53620b82fbbb5aef7f060cac2616eff4 to your computer and use it in GitHub Desktop.
Disable admin panel for the subscribers and add wp-login.php to custom login page
<?php
add_filter( 'show_admin_bar' , 'bd_disable_admin_bar');
function bd_disable_admin_bar($show_admin_bar) {
return ( current_user_can( 'administrator' ) ) ? $show_admin_bar : false;
}
add_action('init','redirect_to_login_page');
function redirect_to_login_page(){
global $pagenow;
if( 'wp-login.php' == $pagenow ) {
wp_redirect('http://site.com/login/');
exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment