Last active
September 18, 2023 18:14
-
-
Save nextab/006715e124b2ea155ff31781aedcc9da to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#region Redirect non-authors back to profile page when accessing /wp-admin | |
function nxt_redirect_non_admin_user() { | |
if(!defined('DOING_AJAX') && !current_user_can('edit_posts')) { | |
wp_redirect(site_url() . '/my-account/'); | |
exit; | |
} | |
} | |
add_action( 'admin_init', 'nxt_redirect_non_admin_user' ); | |
#endregion Redirect non-authors back to home page when accessing /wp-admin | |
#region Disable the WP admin bar for non-authors | |
add_filter('show_admin_bar', function($show) { | |
if(!current_user_can('edit_posts')) { | |
return false; | |
} | |
return $show; | |
}); | |
#endregion Disable the WP admin bar for non-authors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To prevent everything below...