I am using a custom login form imported on my theme's home page through jqModal. In that, when i successfully login it redirects to the same page. I want to redirect based on the logged in user role.

I will prefer a response with some editing in my functions.php or adding a mini plugin. Because I dont want wordpress original files to be edited for future updating hassles.

2 Answers 2


wp_login_form() has the "redirect" parameter.

Define it on the basis of user role.


  • Smart solution. +1!
    – kaiser
    Jul 25, 2011 at 18:12
  • I need to know about any kind of hook. Sorry I am a newbie wordpress developer. I used a custom script for the login within the jqModal. Can you elaborate your answer? basically what you suggested inserts a form itself. But i have a custom form made and want to stick to that. Now I need to know how can I check and redirect just after the authentication. Thanks Jul 26, 2011 at 8:43
  • My answer is not fully correct, sorry. Right is: you should use "redirect" parameter to redirect users to a page where you can check user role first. Then redirect user again to a page intended for certain user role. (Insert input with name "redirect_to" and value equal to url of page where you will check user role)
    – Alexey
    Jul 29, 2011 at 17:15
  • To get user role use this function function get_user_role() { global $current_user; $user_roles = $current_user->roles; $user_role = array_shift($user_roles); return $user_role; }
    – Alexey
    Jul 29, 2011 at 17:21

I used Theme My Login Plugin and modified its templates as per my requirements. I think its the best plugin as per my requirements were concerned. You may check yours.

Also if you want to see the working inside the code, this plugin coding approach is nice and adaptive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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