Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $password = wp_generate_password();
- $userdata = array(
- 'user_login' => $email,
- 'user_email' => $email,
- 'user_pass' => $password,
- 'display_name' => $firstname . ' ' . $name,
- 'first_name' => $firstname,
- 'last_name' => $name,
- 'role' => 'subscriber',
- 'user_registered' => (new DateTime())->format('Y-m-d H:i:s')
- );
- $user_id = wp_insert_user( $userdata ) ;
- // Autologin after registration
- wp_set_current_user($user_id);
- if (wp_validate_auth_cookie()==FALSE)
- {
- wp_set_auth_cookie($user_id, true, false);
- }
- $response = null;
- $current_user = wp_get_current_user();
- var_dump( $current_user );
- object(WP_User)#3217 (7) {
- ["data"]=>
- object(stdClass)#3218 (0) {
- }
- ["ID"]=>
- int(0)
- ["caps"]=>
- array(0) {
- }
- ["cap_key"]=>
- NULL
- ["roles"]=>
- array(0) {
- }
- ["allcaps"]=>
- array(0) {
- }
- ["filter"]=>
- NULL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement