- This topic has 1 reply, 2 voices, and was last updated 5 years, 7 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Troubleshooting › eMember – programmatically login user
i need to programmatically login user so that i can use : Emember_Auth::getInstance()
i m using following code to login user to wordpress
$user=get_user_by(‘id’, $request);
clean_user_cache($request);
wp_clear_auth_cookie();
wp_set_current_user($request);
wp_set_auth_cookie($request, true, false);
update_user_caches($user);
This manages to login user, but doesn’t allow me access Emember_Auth::getInstance()
This is required for JSON feed for my mobile application.
That class can only be accessed after the “plugins_loaded” or “init” hook as been triggered by WordPress. If you try to access it too early in the page load execution cycle, it won’t work since WordPress hasn’t loaded the plugins yet.