0

I am looking to redirect users of a certain role from the dashboard index (/wp-admin/index.php) to a different dashboard page (/wp-admin/admin.php?page=yith_vendor_settings)

There are plugins and code snippets that completely remove access to all dashboard pages, but I only want to redirect the one page to the link above. I still want the user role to be able to access the other admin pages.

add_action(‘init’, ‘blockusers_init’);
function blockusers_init()
{

  //is there a user to check?
  if (isset($user->roles) && is_array($user->roles)) {
    //check for Seller and Page URL
      if (in_array('Seller', $user->roles) && $pageUrl=='https://www.example.co.uk/wp-admin/index.php') {
          $redirect_to = '/wp-admin/admin.php?page=yith_vendor_settings'; // Your redirect URL
      }
  }
  return $redirect_to;
}

Above is my current attempt but this is not working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.