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 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.

share|improve this question

migrated from stackoverflow.com Jul 25 '11 at 15:50

This question came from our site for professional and enthusiast programmers.

2 Answers 2

wp_login_form() has the "redirect" parameter.

Define it on the basis of user role.

http://codex.wordpress.org/Function_Reference/wp_login_form

share|improve this answer
    
Smart solution. +1! –  kaiser Jul 25 '11 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 –  booota Jul 26 '11 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 '11 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 '11 at 17:21
up vote 0 down vote accepted

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.

share|improve this answer

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.