Advertisement
Guest User

Untitled

a guest
Aug 28th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. function custom_login() {
  2. $creds = array();
  3. $creds['user_login'] = 'example';
  4. $creds['user_password'] = 'plaintextpw';
  5. $creds['remember'] = true;
  6. $user = wp_signon( $creds, false );
  7. if ( is_wp_error($user) )
  8. echo $user->get_error_message();
  9. }
  10. // run it before the headers and cookies are sent
  11. add_action( 'after_setup_theme', 'custom_login' );
  12.  
  13. $user_id = username_exists( $user_name );
  14. if ( !$user_id and email_exists($user_email) == false ) {
  15. $random_password = wp_generate_password( $length=12,
  16. $include_standard_special_chars=false );
  17. $user_id = wp_create_user( $user_name, $random_password, $user_email );
  18. } else {
  19. $random_password = __('User already exists. Password inherited.');
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement