/** * Activate a signup. * */ public static function activate_signup($key) { global $wpdb, $current_site; $blog_id = is_object($current_site) ? $current_site->id : false; $signup = GFSignup::get($key); if (is_wp_error($signup)) { return $signup; } $user_id = username_exists($signup->user_login); if ($user_id) { //username already exists, go ahead and mark signup activated and return error message $signup->set_as_activated(); return new WP_Error('user_already_exists', __('That username is already activated.'), $signup); } if (email_exists($signup->user_email)) { //email address already exists, return error message return new WP_Error('email_already_exists', __('Sorry, that email address is already used!'), $signup); } // unbind site creation from gform_user_registered hook, run it manually below if (is_multisite()) { remove_action('gform_user_registered', array('GFUser', 'create_new_multisite')); } $user_data = GFUser::create_user($signup->lead, $signup->form, $signup->config); $user_id = rgar($user_data, 'user_id'); if (!$user_id) { return new WP_Error('create_user', __('Could not create user'), $signup); } $signup->set_as_activated(); do_action('gform_activate_user', $user_id, $user_data, $signup->meta); if (is_multisite()) { $ms_options = rgars($signup->config, 'meta/multisite_options'); if ($ms_options['create_site']) { $blog_id = GFUser::create_new_multisite($user_id, $signup->config, $signup->lead, $user_data['password']); } } return array('user_id' => $user_id, 'password' => $user_data['password'], 'blog_id' => $blog_id); }