Advertisement
Guest User

Untitled

a guest
Aug 29th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. // Generate the password and create the user
  2. $password = wp_generate_password( 12, false );
  3. $user_id = wp_create_user( $email_address, $password, $email_address );
  4.  
  5. //login
  6. wp_clear_auth_cookie();
  7. wp_set_current_user ( $user_id );
  8. wp_set_auth_cookie ( $user_id );
  9.  
  10. // Set the role
  11. $user = new WP_User( $user_id );
  12. $user->set_role( 'subscriber' );
  13.  
  14. //Ready data for linked post type creation
  15. $new_post = array(
  16. 'post_content' => $email_address,
  17. 'post_status' => 'publish',
  18. 'post_date' => date('Y-m-d H:i:s'),
  19. 'post_author' => $user_id,
  20. 'post_title' => $post_name,
  21. 'post_name' => $post_name,
  22. 'post_type' => $user_type
  23. );
  24.  
  25. //Create the post
  26. $account_link_post_id = wp_insert_post($new_post);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement