/** * Process data submitted at user registration and convert to a signup object. * * @since 1.2.0 * * @todo There appears to be a bug in the return value on success. * * @param string $user_login Login name requested by the user. * @param string $user_password Password requested by the user. * @param string $user_email Email address entered by the user. * @param array $usermeta Miscellaneous metadata about the user (blog-specific * signup data, xprofile data, etc). * @return bool|WP_Error True on success, WP_Error on failure. */ function bp_core_signup_user($user_login, $user_password, $user_email, $usermeta) { $bp = buddypress(); // We need to cast $user_id to pass to the filters. $user_id = false; // Multisite installs have their own install procedure. if (is_multisite()) { wpmu_signup_user($user_login, $user_email, $usermeta); } else { // Format data. $user_login = preg_replace('/\\s+/', '', sanitize_user($user_login, true)); $user_email = sanitize_email($user_email); $activation_key = wp_generate_password(32, false); /** * WordPress's default behavior is to create user accounts * immediately at registration time. BuddyPress uses a system * borrowed from WordPress Multisite, where signups are stored * separately and accounts are only created at the time of * activation. For backward compatibility with plugins that may * be anticipating WP's default behavior, BP silently creates * accounts for registrations (though it does not use them). If * you know that you are not running any plugins dependent on * these pending accounts, you may want to save a little DB * clutter by defining setting the BP_SIGNUPS_SKIP_USER_CREATION * to true in your wp-config.php file. */ if (!defined('BP_SIGNUPS_SKIP_USER_CREATION') || !BP_SIGNUPS_SKIP_USER_CREATION) { $user_id = BP_Signup::add_backcompat($user_login, $user_password, $user_email, $usermeta); if (is_wp_error($user_id)) { return $user_id; } bp_update_user_meta($user_id, 'activation_key', $activation_key); } $args = array('user_login' => $user_login, 'user_email' => $user_email, 'activation_key' => $activation_key, 'meta' => $usermeta); BP_Signup::add($args); /** * Filters if BuddyPress should send an activation key for a new signup. * * @since 1.2.3 * * @param bool $value Whether or not to send the activation key. * @param int $user_id User ID to send activation key to. * @param string $user_email User email to send activation key to. * @param string $activation_key Activation key to be sent. * @param array $usermeta Miscellaneous metadata about the user (blog-specific * signup data, xprofile data, etc). */ if (apply_filters('bp_core_signup_send_activation_key', true, $user_id, $user_email, $activation_key, $usermeta)) { bp_core_signup_send_validation_email($user_id, $user_email, $activation_key, $user_login); } } $bp->signup->username = $user_login; /** * Fires at the end of the process to sign up a user. * * @since 1.2.2 * * @param bool|WP_Error $user_id True on success, WP_Error on failure. * @param string $user_login Login name requested by the user. * @param string $user_password Password requested by the user. * @param string $user_email Email address requested by the user. * @param array $usermeta Miscellaneous metadata about the user (blog-specific * signup data, xprofile data, etc). */ do_action('bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta); return $user_id; }
/** * Process data submitted at user registration and convert to a signup object. * * @todo There appears to be a bug in the return value on success. * * @param string $user_login Login name requested by the user. * @param string $user_password Password requested by the user. * @param string $user_email Email address entered by the user. * @param array $usermeta Miscellaneous metadata about the user (blog-specific * signup data, xprofile data, etc). * @return bool|WP_Error True on success, WP_Error on failure. */ function bp_core_signup_user($user_login, $user_password, $user_email, $usermeta) { $bp = buddypress(); // We need to cast $user_id to pass to the filters $user_id = false; // Multisite installs have their own install procedure if (is_multisite()) { wpmu_signup_user($user_login, $user_email, $usermeta); } else { // Format data $user_login = preg_replace('/\\s+/', '', sanitize_user($user_login, true)); $user_email = sanitize_email($user_email); $activation_key = substr(md5(time() . rand() . $user_email), 0, 16); /** * WordPress's default behavior is to create user accounts * immediately at registration time. BuddyPress uses a system * borrowed from WordPress Multisite, where signups are stored * separately and accounts are only created at the time of * activation. For backward compatibility with plugins that may * be anticipating WP's default behavior, BP silently creates * accounts for registrations (though it does not use them). If * you know that you are not running any plugins dependent on * these pending accounts, you may want to save a little DB * clutter by defining setting the BP_SIGNUPS_SKIP_USER_CREATION * to true in your wp-config.php file. */ if (!defined('BP_SIGNUPS_SKIP_USER_CREATION') || !BP_SIGNUPS_SKIP_USER_CREATION) { $user_id = BP_Signup::add_backcompat($user_login, $user_password, $user_email, $usermeta); if (is_wp_error($user_id)) { return $user_id; } $activation_key = wp_hash($user_id); update_user_meta($user_id, 'activation_key', $activation_key); } $args = array('user_login' => $user_login, 'user_email' => $user_email, 'activation_key' => $activation_key, 'meta' => $usermeta); BP_Signup::add($args); if (apply_filters('bp_core_signup_send_activation_key', true, $user_id, $user_email, $activation_key, $usermeta)) { bp_core_signup_send_validation_email($user_id, $user_email, $activation_key); } } $bp->signup->username = $user_login; do_action('bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta); return $user_id; }