Last active
October 17, 2021 23:35
-
-
Save mattneal-stafflink/3ca46ac49a02ccfa8f5c5c8f3c696608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Stop Authors from accessing the admin dashboard unless you are an admin. | |
function prevent_author_access(){ | |
if( current_user_can( 'author' ) && is_admin() ) { | |
// do something here. maybe redirect to homepage | |
wp_safe_redirect( get_bloginfo( 'url' ) ); | |
} | |
} | |
add_action( 'admin_init', 'prevent_author_access' ); | |
// Remove the admin bar for all users except for admins. | |
add_action('after_setup_theme', 'remove_admin_bar'); | |
function remove_admin_bar() { | |
if (!current_user_can('administrator') && !is_admin()) { | |
show_admin_bar(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy all of this (without the '<?php') and paste it into your themes' functions.php.