signup_user

Setup the new user signup process.

Description

signup_user( (string) $user_name = '', (string) $user_email = '', (string) $errors = '' ); 

Parameters (3)

0. $user_name — Optional. (string) => ''
The user name.
1. $user_email — Optional. (string) => ''
The user's email.
2. $errors — Optional. (string) => ''
A WP_Error object containing existing errors. Defaults to empty string.

Usage

  1. if ( !function_exists( 'signup_user' ) ) { 
  2. require_once '/wp-signup.php'; 
  3.  
  4. // The user name. 
  5. $user_name = ''; 
  6.  
  7. // The user's email. 
  8. $user_email = ''; 
  9.  
  10. // A WP_Error object containing existing errors. Defaults to empty string. 
  11. $errors = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = signup_user($user_name, $user_email, $errors); 
  15.  

Defined (1)

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

/wp-signup.php  
  1. function signup_user( $user_name = '', $user_email = '', $errors = '' ) { 
  2. global $active_signup; 
  3.  
  4. if ( !is_wp_error($errors) ) 
  5. $errors = new WP_Error(); 
  6.  
  7. $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog'; 
  8.  
  9. $signup_user_defaults = array( 
  10. 'user_name' => $user_name,  
  11. 'user_email' => $user_email,  
  12. 'errors' => $errors,  
  13. ); 
  14.  
  15. /** 
  16. * Filters the default user variables used on the user sign-up form. 
  17. * @since 3.0.0 
  18. * @param array $signup_user_defaults { 
  19. * An array of default user variables. 
  20. * @type string $user_name The user username. 
  21. * @type string $user_email The user email address. 
  22. * @type WP_Error $errors A WP_Error object with possible errors relevant to the sign-up user. 
  23. * } 
  24. */ 
  25. $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); 
  26. $user_name = $filtered_results['user_name']; 
  27. $user_email = $filtered_results['user_email']; 
  28. $errors = $filtered_results['errors']; 
  29.  
  30. ?> 
  31.  
  32. <h2><?php 
  33. /** translators: %s: name of the network */ 
  34. printf( __( 'Get your own %s account in seconds' ), get_network()->site_name ); 
  35. ?></h2> 
  36. <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> 
  37. <input type="hidden" name="stage" value="validate-user-signup" /> 
  38. <?php 
  39. /** This action is documented in wp-signup.php */ 
  40. do_action( 'signup_hidden_fields', 'validate-user' ); 
  41. ?> 
  42. <?php show_user_form($user_name, $user_email, $errors); ?> 
  43.  
  44. <p> 
  45. <?php if ( $active_signup == 'blog' ) { ?> 
  46. <input id="signupblog" type="hidden" name="signup_for" value="blog" /> 
  47. <?php } elseif ( $active_signup == 'user' ) { ?> 
  48. <input id="signupblog" type="hidden" name="signup_for" value="user" /> 
  49. <?php } else { ?> 
  50. <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> /> 
  51. <label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label> 
  52. <br /> 
  53. <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> /> 
  54. <label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label> 
  55. <?php } ?> 
  56. </p> 
  57.  
  58. <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p> 
  59. </form> 
  60. <?php