Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to redirect users to an admin page if they access another admin page?

For example if they a user ever hits "all pages" /wp-admin/edit.php?post_type=page

they would get redirected to "add New page" /wp-admin/post-new.php?post_type=page

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted
/**
 * Redirect admin pages.
 *
 * Redirect specific admin page to another specific admin page.
 *
 * @author Michael Ecklund
 * @access public
 *
 * @return void
 */
public function disallowed_admin_pages(){
    global $pagenow;
    /* Check current admin page. */
    if($pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'page'){
        wp_redirect(admin_url('/post-new.php?post_type=page', 'http'), 301);
        exit;
    }
}

Fire the above function on the hook admin_init.

add_action('admin_init', array($this, 'disallowed_admin_pages'));

share|improve this answer
add comment

Yes this is possible by adding an action to admin_init, at that point you could check the request uri to see if it matches /wp-admin/edit.php?post_type=page and if it does issue a redirect to the add posts page: /wp-admin/post-new.php?post_type=page.

Also the Plugin API and the action reference pages on the WordPress codex go into more detail about actions and how they work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.