/** * Set up the signups admin page. * * Loaded before the page is rendered, this function does all initial * setup, including: processing form requests, registering contextual * help, and setting up screen options. * * @since 2.0.0 * * @global $bp_members_signup_list_table */ public function signups_admin_load() { global $bp_members_signup_list_table; // Build redirection URL. $redirect_to = remove_query_arg(array('action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids'), $_SERVER['REQUEST_URI']); $doaction = bp_admin_list_table_current_bulk_action(); /** * Fires at the start of the signups admin load. * * @since 2.0.0 * * @param string $doaction Current bulk action being processed. * @param array $_REQUEST Current $_REQUEST global. */ do_action('bp_signups_admin_load', $doaction, $_REQUEST); /** * Filters the allowed actions for use in the user signups admin page. * * @since 2.0.0 * * @param array $value Array of allowed actions to use. */ $allowed_actions = apply_filters('bp_signups_admin_allowed_actions', array('do_delete', 'do_activate', 'do_resend')); // Prepare the display of the Community Profile screen. if (!in_array($doaction, $allowed_actions) || -1 == $doaction) { if (is_network_admin()) { $bp_members_signup_list_table = self::get_list_table_class('BP_Members_MS_List_Table', 'ms-users'); } else { $bp_members_signup_list_table = self::get_list_table_class('BP_Members_List_Table', 'users'); } // The per_page screen option. add_screen_option('per_page', array('label' => _x('Pending Accounts', 'Pending Accounts per page (screen options)', 'buddypress'))); get_current_screen()->add_help_tab(array('id' => 'bp-signups-overview', 'title' => __('Overview', 'buddypress'), 'content' => '<p>' . __('This is the administration screen for pending accounts on your site.', 'buddypress') . '</p>' . '<p>' . __('From the screen options, you can customize the displayed columns and the pagination of this screen.', 'buddypress') . '</p>' . '<p>' . __('You can reorder the list of your pending accounts by clicking on the Username, Email or Registered column headers.', 'buddypress') . '</p>' . '<p>' . __('Using the search form, you can find pending accounts more easily. The Username and Email fields will be included in the search.', 'buddypress') . '</p>')); get_current_screen()->add_help_tab(array('id' => 'bp-signups-actions', 'title' => __('Actions', 'buddypress'), 'content' => '<p>' . __('Hovering over a row in the pending accounts list will display action links that allow you to manage pending accounts. You can perform the following actions:', 'buddypress') . '</p>' . '<ul><li>' . __('"Email" takes you to the confirmation screen before being able to send the activation link to the desired pending account. You can only send the activation email once per day.', 'buddypress') . '</li>' . '<li>' . __('"Delete" allows you to delete a pending account from your site. You will be asked to confirm this deletion.', 'buddypress') . '</li></ul>' . '<p>' . __('By clicking on a Username you will be able to activate a pending account from the confirmation screen.', 'buddypress') . '</p>' . '<p>' . __('Bulk actions allow you to perform these 3 actions for the selected rows.', 'buddypress') . '</p>')); // Help panel - sidebar links. get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:', 'buddypress') . '</strong></p>' . '<p>' . __('<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress') . '</p>'); // Add accessible hidden headings and text for the Pending Users screen. if (bp_get_major_wp_version() >= 4.4) { get_current_screen()->set_screen_reader_content(array('heading_views' => __('Filter users list', 'buddypress'), 'heading_pagination' => __('Pending users list navigation', 'buddypress'), 'heading_list' => __('Pending users list', 'buddypress'))); } } else { if (!empty($_REQUEST['signup_ids'])) { $signups = wp_parse_id_list($_REQUEST['signup_ids']); } // Handle resent activation links. if ('do_resend' == $doaction) { // Nonce check. check_admin_referer('signups_resend'); $resent = BP_Signup::resend($signups); if (empty($resent)) { $redirect_to = add_query_arg('error', $doaction, $redirect_to); } else { $query_arg = array('updated' => 'resent'); if (!empty($resent['resent'])) { $query_arg['resent'] = count($resent['resent']); } if (!empty($resent['errors'])) { $query_arg['notsent'] = count($resent['errors']); set_transient('_bp_admin_signups_errors', $resent['errors'], 30); } $redirect_to = add_query_arg($query_arg, $redirect_to); } bp_core_redirect($redirect_to); // Handle activated accounts. } elseif ('do_activate' == $doaction) { // Nonce check. check_admin_referer('signups_activate'); $activated = BP_Signup::activate($signups); if (empty($activated)) { $redirect_to = add_query_arg('error', $doaction, $redirect_to); } else { $query_arg = array('updated' => 'activated'); if (!empty($activated['activated'])) { $query_arg['activated'] = count($activated['activated']); } if (!empty($activated['errors'])) { $query_arg['notactivated'] = count($activated['errors']); set_transient('_bp_admin_signups_errors', $activated['errors'], 30); } $redirect_to = add_query_arg($query_arg, $redirect_to); } bp_core_redirect($redirect_to); // Handle sign-ups delete. } elseif ('do_delete' == $doaction) { // Nonce check. check_admin_referer('signups_delete'); $deleted = BP_Signup::delete($signups); if (empty($deleted)) { $redirect_to = add_query_arg('error', $doaction, $redirect_to); } else { $query_arg = array('updated' => 'deleted'); if (!empty($deleted['deleted'])) { $query_arg['deleted'] = count($deleted['deleted']); } if (!empty($deleted['errors'])) { $query_arg['notdeleted'] = count($deleted['errors']); set_transient('_bp_admin_signups_errors', $deleted['errors'], 30); } $redirect_to = add_query_arg($query_arg, $redirect_to); } bp_core_redirect($redirect_to); // Plugins can update other stuff from here. } else { $this->redirect = $redirect_to; /** * Fires at end of signups admin load if doaction does not match any actions. * * @since 2.0.0 * * @param string $doaction Current bulk action being processed. * @param array $_REQUEST Current $_REQUEST global. * @param string $redirect Determined redirect url to send user to. */ do_action('bp_members_admin_update_signups', $doaction, $_REQUEST, $this->redirect); bp_core_redirect($this->redirect); } } }
/** * @group activate */ public function test_activate_user_accounts_with_blogs() { global $wpdb, $current_site, $base; if (!is_multisite()) { return; } $signups = array(); // Can't trust this first signup :( $signups['testpath1'] = $this->factory->signup->create(array('user_login' => 'testpath1', 'user_email' => '*****@*****.**', 'domain' => '', 'path' => '', 'title' => '', 'activation_key' => 'activationkeyblogone')); $signups['blogtwo'] = $this->factory->signup->create(array('user_login' => 'blogtwo', 'user_email' => '*****@*****.**', 'domain' => $current_site->domain, 'path' => $base . 'blogtwo', 'title' => 'Blog Two', 'activation_key' => 'activationkeyblogtwo')); $signups['blogthree'] = $this->factory->signup->create(array('user_login' => 'blogthree', 'user_email' => '*****@*****.**', 'domain' => '', 'path' => '', 'title' => '', 'activation_key' => 'activationkeyblogthree')); $signups['blogfour'] = $this->factory->signup->create(array('user_login' => 'blogfour', 'user_email' => '*****@*****.**', 'domain' => $current_site->domain, 'path' => $base . 'blogfour', 'title' => 'Blog Four', 'activation_key' => 'activationkeyblogfour')); // Neutralize db errors $suppress = $wpdb->suppress_errors(); $results = BP_Signup::activate($signups); $wpdb->suppress_errors($suppress); $this->assertNotEmpty($results['activated']); $users = array(); foreach ($signups as $login => $signup_id) { $users[$login] = get_user_by('login', $login); } $this->assertEqualSets($results['activated'], wp_list_pluck($users, 'ID')); $blogs = array(); foreach ($users as $path => $user) { // Can't trust this first signup :( if ('testpath1' == $path) { continue; } $blogs[$path] = get_active_blog_for_user($user->ID); } $blogs = array_filter($blogs); $blogs = array_map('basename', wp_list_pluck($blogs, 'path')); $this->assertEqualSets($blogs, array_keys($blogs)); }