Web Development. Client Satisfaction. Web Consultancy. Professional. UX. Fast. Responsive Design. Dynamic. Interactive. Innovative. Ecommerce. Wordpress plugins. Prestashop modules. You name it.

How To Make Programmatically WordPress Login PHP

How To Make Programmatically WordPress Login PHP

In this tutorial we will try to programmatically login user using PHP. This functionality is usefull when you create a custom registration form and after registration you auto login the user in his account. Or if you want to register user account for an easy login.

Programmatically Wordpress Login PHP

In order to successfully autologin the user in his account, the only thing you need to do this, is his user id. After you get the user id everything is straightforward. 

wp_set_auth_cookie($user_id, true, false);
$user = get_user_by('id', $user_id);

The above code is all you need to programmatically login any user in wordpress. Let me know if you need any help with this implementation.

Leave a Reply

Notify of