WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Try this plugin. User Switching

share|improve this answer

Your Answer


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.