bp_core_signup_user

Process data submitted at user registration and convert to a signup object.

Description

(bool|WP_Error) bp_core_signup_user( (string) $user_login, (string) $user_password, (string) $user_email, (array) $usermeta ); 

Returns (bool|WP_Error)

True on success, WP_Error on failure.

Parameters (4)

0. $user_login (string)
Login name requested by the user.
1. $user_password (string)
Password requested by the user.
2. $user_email (string)
Email address entered by the user.
3. $usermeta (array)
Miscellaneous metadata about the user (blog-specific signup data, xprofile data, etc).

Usage

  1. if ( !function_exists( 'bp_core_signup_user' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php'; 
  3.  
  4. // Login name requested by the user. 
  5. $user_login = ''; 
  6.  
  7. // Password requested by the user. 
  8. $user_password = ''; 
  9.  
  10. // Email address entered by the user. 
  11. $user_email = ''; 
  12.  
  13. // Miscellaneous metadata about the user (blog-specific 
  14. // signup data, xprofile data, etc). 
  15. $usermeta = array(); 
  16.  
  17. // NOTICE! Understand what this does before running. 
  18. $result = bp_core_signup_user($user_login, $user_password, $user_email, $usermeta); 
  19.  

Defined (1)

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

/bp-members/bp-members-functions.php  
  1. function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) { 
  2. $bp =buddypress); 
  3.  
  4. // We need to cast $user_id to pass to the filters. 
  5. $user_id = false; 
  6.  
  7. // Multisite installs have their own install procedure. 
  8. if ( is_multisite() ) { 
  9. wpmu_signup_user( $user_login, $user_email, $usermeta ); 
  10.  
  11. } else { 
  12. // Format data. 
  13. $user_login = preg_replace( '/\s+/', '', sanitize_user( $user_login, true ) ); 
  14. $user_email = sanitize_email( $user_email ); 
  15. $activation_key = wp_generate_password( 32, false ); 
  16.  
  17. /** 
  18. * WordPress's default behavior is to create user accounts 
  19. * immediately at registration time. BuddyPress uses a system 
  20. * borrowed from WordPress Multisite, where signups are stored 
  21. * separately and accounts are only created at the time of 
  22. * activation. For backward compatibility with plugins that may 
  23. * be anticipating WP's default behavior, BP silently creates 
  24. * accounts for registrations (though it does not use them). If 
  25. * you know that you are not running any plugins dependent on 
  26. * these pending accounts, you may want to save a little DB 
  27. * clutter by defining setting the BP_SIGNUPS_SKIP_USER_CREATION 
  28. * to true in your wp-config.php file. 
  29. */ 
  30. if ( ! defined( 'BP_SIGNUPS_SKIP_USER_CREATION' ) || ! BP_SIGNUPS_SKIP_USER_CREATION ) { 
  31. $user_id = BP_Signup::add_backcompat( $user_login, $user_password, $user_email, $usermeta ); 
  32.  
  33. if ( is_wp_error( $user_id ) ) { 
  34. return $user_id; 
  35.  
  36. bp_update_user_meta( $user_id, 'activation_key', $activation_key ); 
  37.  
  38. $args = array( 
  39. 'user_login' => $user_login,  
  40. 'user_email' => $user_email,  
  41. 'activation_key' => $activation_key,  
  42. 'meta' => $usermeta,  
  43. ); 
  44.  
  45. BP_Signup::add( $args ); 
  46.  
  47. /** 
  48. * Filters if BuddyPress should send an activation key for a new signup. 
  49. * @since 1.2.3 
  50. * @param bool $value Whether or not to send the activation key. 
  51. * @param int $user_id User ID to send activation key to. 
  52. * @param string $user_email User email to send activation key to. 
  53. * @param string $activation_key Activation key to be sent. 
  54. * @param array $usermeta Miscellaneous metadata about the user (blog-specific 
  55. * signup data, xprofile data, etc). 
  56. */ 
  57. if ( apply_filters( 'bp_core_signup_send_activation_key', true, $user_id, $user_email, $activation_key, $usermeta ) ) { 
  58. bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key, $user_login ); 
  59.  
  60. $bp->signup->username = $user_login; 
  61.  
  62. /** 
  63. * Fires at the end of the process to sign up a user. 
  64. * @since 1.2.2 
  65. * @param bool|WP_Error $user_id True on success, WP_Error on failure. 
  66. * @param string $user_login Login name requested by the user. 
  67. * @param string $user_password Password requested by the user. 
  68. * @param string $user_email Email address requested by the user. 
  69. * @param array $usermeta Miscellaneous metadata about the user (blog-specific 
  70. * signup data, xprofile data, etc). 
  71. */ 
  72. do_action( 'bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta ); 
  73.  
  74. return $user_id;