1

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

2 Answers 2

9

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.

5

Try this plugin. User Switching

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.