How to redirect specific post type with user role

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:

Read More

enter image description here

Related posts

1 comment

  1. 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();
      }
    }
    

Comments are closed.