um_add_user_frontend

The Ultimate Member um add user frontend function.

Description

um_add_user_frontend( $args ); 

Parameters (1)

0. $args
The args.

Usage

  1. if ( !function_exists( 'um_add_user_frontend' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ultimate-member/core/um-actions-register.php'; 
  3.  
  4. // The args. 
  5. $args = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = um_add_user_frontend($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/core/um-actions-register.php  
  1. function um_add_user_frontend($args) { 
  2. global $ultimatemember; 
  3.  
  4. unset( $args['user_id'] ); 
  5.  
  6. extract($args); 
  7.  
  8.  
  9. if ( isset( $username ) && !isset($args['user_login']) ) { 
  10. $user_login = $username; 
  11.  
  12. if ( ! empty( $first_name ) && ! empty( $last_name ) && ! isset( $user_login ) ) { 
  13.  
  14. if ( um_get_option('permalink_base') == 'name' ) { 
  15. $user_login = rawurlencode( strtolower( str_replace(" ", ".", $first_name." ".$last_name ) ) ); 
  16. }else if ( um_get_option('permalink_base') == 'name_dash' ) { 
  17. $user_login = rawurlencode( strtolower( str_replace(" ", "-", $first_name." ".$last_name ) ) ); 
  18. }else if ( um_get_option('permalink_base') == 'name_plus' ) { 
  19. $user_login = strtolower( str_replace(" ", "+", $first_name." ".$last_name ) ); 
  20. }else{ 
  21. $user_login = strtolower( str_replace(" ", "", $first_name." ".$last_name ) ); 
  22.  
  23. // if full name exists 
  24. $count = 1; 
  25. while( username_exists( $user_login ) ) { 
  26. $user_login .= $count; 
  27. $count++; 
  28.  
  29. if( !isset( $user_login ) && isset( $user_email ) && $user_email ) 
  30. $user_login = $user_email; 
  31.  
  32. $unique_userID = $ultimatemember->query->count_users() + 1; 
  33.  
  34. if ( ! isset( $user_login ) || strlen( $user_login ) > 30 ) { 
  35. $user_login = 'user' . $unique_userID; 
  36.  
  37. if ( isset( $username ) && is_email( $username ) ) { 
  38. $user_email = $username; 
  39.  
  40. if ( ! isset( $user_password ) ) { 
  41. $user_password = $ultimatemember->validation->generate( 8 ); 
  42.  
  43.  
  44. if( ! isset( $user_email ) ) { 
  45. $site_url = @$_SERVER['SERVER_NAME']; 
  46. $user_email = 'nobody' . $unique_userID . '@' . $site_url; 
  47. $user_email = apply_filters("um_user_register_submitted__email", $user_email ); 
  48.  
  49.  
  50. $creds['user_login'] = $user_login; 
  51. $creds['user_password'] = $user_password; 
  52. $creds['user_email'] = $user_email; 
  53.  
  54. $args['submitted'] = array_merge( $args['submitted'], $creds); 
  55. $args = array_merge($args, $creds); 
  56.  
  57. unset( $args['user_id'] ); 
  58.  
  59. do_action('um_before_new_user_register', $args); 
  60.  
  61. $user_id = wp_create_user( $user_login, $user_password, $user_email ); 
  62.  
  63. do_action('um_after_new_user_register', $user_id, $args); 
  64.  
  65. return $user_id;