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.

I have created custom post type Books in my functions.php. Now I want to redirect every user (assigned with editor role). When they click to Dashboard it goes to this page:

http://www.localhost/wordpress/wp-admin/edit.php?post_type=product

What I want:

enter image description here

share|improve this question

1 Answer 1

up vote 2 down vote accepted
add_action('load-index.php', 'redirect_dashboard');

function redirect_dashboard() {
  if ( ! is_admin() || current_user_can('activate_plugins') ) return;
  $screen = get_current_screen();
  if ( is_object($screen) && $screen->base == 'dashboard' ) {
    $url = admin_url('edit.php');
    wp_safe_redirect( add_query_arg( array('post_type' => 'product'), $url) );
    die();
  }
}
share|improve this answer
    
It is also affecting to main administrator page. I want only editor role otherwise you code is perfect for me. Can you help me how to fix that also. –  Avenger Aug 31 '13 at 2:03
    
@Manan I've edited the code. Just a little addition on first if. In the question you said "i want to redirect every user" not "i want to redirect every editor" or I would use this code on first publish. –  G. M. Aug 31 '13 at 2:14
    
Thank you G. M. :) –  Avenger Sep 1 '13 at 5:14

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.