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 2 kinds of users...

Both uses custom form for registeration....

One is parent user and another is child users. Parent user can register and then login and create child users. I have also given interface in theme where parents can manage child users data created by them.

Basically site is based on article for childs helping them in education and question answer....

What i want to do is when parent is login , i have list of his child users, want to give link like Login as child, on click of which parent gets logout and get logged in as child using child credential...

Any tips/suggestion how to achive logout and login as different user using script...

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

To login as a user you just need the target user ID and these two functions:

wp_set_current_user( $user_id );
wp_set_auth_cookie( $user_id );

If you do this mid-page, make sure you refresh it to reflect the changes.

share|improve this answer
add comment

Try this plugin. User Switching

share|improve this answer
add comment

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.