Created
September 25, 2013 20:37
-
-
Save rsharrer/6705672 to your computer and use it in GitHub Desktop.
WP-Functions /Redirect admin pages to any location
Redirecting the admin pages was something I needed to do for a recent project. The following snippet will let you redirect any of the admin pages to any location you wish based on the user ‘capability’. Another option would be to replace wp_redirect with wp_die(“some custom message”); to display…
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
function wps_admin_pages_redirect() { | |
global $pagenow; | |
$admin_pages = array( | |
'edit-tags.php?taxonomy=category', | |
'edit-tags.php?taxonomy=post_tag', | |
'link-manager.php', | |
'options-writing.php', | |
'options-reading.php', | |
'options-discussion.php', | |
'options-media.php', | |
'options-privacy.php', | |
'options-permalink.php', | |
); | |
if(in_array($pagenow, $admin_pages)){ | |
wp_redirect( admin_url('/') ); exit; | |
} | |
} | |
if(!current_user_can('edit_post')){ | |
add_action('admin_init', 'wps_admin_pages_redirect'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment