Skip to content

Instantly share code, notes, and snippets.

@Shoora
Forked from miziomon/admin-redirect
Created March 25, 2024 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shoora/d36dc7a49bfbe308e3106b8525a79c2a to your computer and use it in GitHub Desktop.
Save Shoora/d36dc7a49bfbe308e3106b8525a79c2a to your computer and use it in GitHub Desktop.
WordPress user admin redirect
/**
*
* redirect to homepage if has non "edit_posts" capabilities
*/
add_filter("admin_init", function () {
if (!current_user_can('edit_posts')) {
wp_redirect(WP_HOME);
exit;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment