BP_Members_Admin::signups_admin_manage( string $action = '' )

This is the confirmation screen for actions.

Description

Parameters

$action

(string) (Optional) Delete, activate, or resend activation link.

Default value: ''

Return

(null|false)

Source

File: bp-members/classes/class-bp-members-admin.php

	public function signups_admin_manage( $action = '' ) {
		if ( ! current_user_can( $this->capability ) || empty( $action ) ) {
			die( '-1' );
		}

		// Get the user IDs from the URL.
		$ids = false;
		if ( ! empty( $_POST['allsignups'] ) ) {
			$ids = wp_parse_id_list( $_POST['allsignups'] );
		} elseif ( ! empty( $_GET['signup_id'] ) ) {
			$ids = absint( $_GET['signup_id'] );
		}

		if ( empty( $ids ) ) {
			return false;
		}

		// Query for signups, and filter out those IDs that don't
		// correspond to an actual signup.
		$signups_query = BP_Signup::get( array(
			'include' => $ids,
		) );

		$signups    = $signups_query['signups'];
		$signup_ids = wp_list_pluck( $signups, 'signup_id' );

		// Set up strings.
		switch ( $action ) {
			case 'delete' :
				$header_text = __( 'Delete Pending Accounts', 'buddyboss' );
				if ( 1 == count( $signup_ids ) ) {
					$helper_text = __( 'You are about to delete the following account:', 'buddyboss' );
				} else {
					$helper_text = __( 'You are about to delete the following accounts:', 'buddyboss' );
				}
				break;

			case 'activate' :
				$header_text = __( 'Activate Pending Accounts', 'buddyboss' );
				if ( 1 == count( $signup_ids ) ) {
					$helper_text = __( 'You are about to activate the following account:', 'buddyboss' );
				} else {
					$helper_text = __( 'You are about to activate the following accounts:', 'buddyboss' );
				}
				break;

			case 'resend' :
				$header_text = __( 'Resend Activation Emails', 'buddyboss' );
				if ( 1 == count( $signup_ids ) ) {
					$helper_text = __( 'You are about to resend an activation email to the following account:', 'buddyboss' );
				} else {
					$helper_text = __( 'You are about to resend an activation email to the following accounts:', 'buddyboss' );
				}
				break;
		}

		// These arguments are added to all URLs.
		$url_args = array( 'page' => 'bp-signups' );

		// These arguments are only added when performing an action.
		$action_args = array(
			'action'     => 'do_' . $action,
			'signup_ids' => implode( ',', $signup_ids )
		);

		if ( is_network_admin() ) {
			$base_url = network_admin_url( 'users.php' );
		} else {
			$base_url = bp_get_admin_url( 'users.php' );
		}

		$cancel_url = add_query_arg( $url_args, $base_url );
		$action_url = wp_nonce_url(
			add_query_arg(
				array_merge( $url_args, $action_args ),
				$base_url
			),
			'signups_' . $action
		);

		// Prefetch registration field data.
		$fdata = array();
		if ( 'activate' === $action && bp_is_active( 'xprofile' ) ) {
			$field_groups = bp_xprofile_get_groups( array(
				'exclude_fields'    => 1,
				'update_meta_cache' => false,
				'fetch_fields'      => true,
			) );

			foreach( $field_groups as $fg ) {
				foreach( $fg->fields as $f ) {
					$fdata[ $f->id ] = $f->name;
				}
			}
		}

		?>

		<div class="wrap">
			<h1><?php echo esc_html( $header_text ); ?></h1>
			<p><?php echo esc_html( $helper_text ); ?></p>

			<ol class="bp-signups-list">
			<?php foreach ( $signups as $signup ) :
				$last_notified = mysql2date( 'Y/m/d g:i:s a', $signup->date_sent );
				$profile_field_ids = array();

				// Get all xprofile field IDs except field 1.
				if ( ! empty( $signup->meta['profile_field_ids'] ) ) {
					$profile_field_ids = array_flip( explode( ',', $signup->meta['profile_field_ids'] ) );
					unset( $profile_field_ids[1] );
				} ?>

				<li>
					<strong><?php echo esc_html( $signup->user_login ) ?></strong>

					<?php if ( 'activate' == $action ) : ?>
						<table class="wp-list-table widefat fixed striped">
							<tbody>
								<tr>
									<td class="column-fields"><?php esc_html_e( 'Display Name', 'buddyboss' ); ?></td>
									<td><?php echo esc_html( $signup->user_name ); ?></td>
								</tr>

								<tr>
									<td class="column-fields"><?php esc_html_e( 'Email', 'buddyboss' ); ?></td>
									<td><?php echo sanitize_email( $signup->user_email ); ?></td>
								</tr>

								<?php if ( bp_is_active( 'xprofile' ) && ! empty( $profile_field_ids ) ) : ?>
									<?php foreach ( $profile_field_ids as $pid => $noop ) :
										$field_value = isset( $signup->meta[ "field_{$pid}" ] ) ? $signup->meta[ "field_{$pid}" ] : ''; ?>
										<tr>
											<td class="column-fields"><?php echo esc_html( $fdata[ $pid ] ); ?></td>
											<td><?php echo $this->format_xprofile_field_for_display( $field_value ); ?></td>
										</tr>

									<?php endforeach;  ?>

								<?php endif; ?>

							</tbody>
						</table>
					<?php endif; ?>

					<?php if ( 'resend' == $action ) : ?>

						<p class="description">
							<?php printf( esc_html__( 'Last notified: %s', 'buddyboss'), $last_notified ) ;?>

							<?php if ( ! empty( $signup->recently_sent ) ) : ?>

								<span class="attention wp-ui-text-notification"> <?php esc_html_e( '(less than 24 hours ago)', 'buddyboss' ); ?></span>

							<?php endif; ?>
						</p>

					<?php endif; ?>

				</li>

			<?php endforeach; ?>
			</ol>

			<?php if ( 'delete' === $action ) : ?>

				<p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddyboss' ) ?></strong></p>

			<?php endif ; ?>

			<a class="button-primary" href="<?php echo esc_url( $action_url ); ?>"><?php esc_html_e( 'Confirm', 'buddyboss' ); ?></a>
			<a class="button" href="<?php echo esc_url( $cancel_url ); ?>"><?php esc_html_e( 'Cancel', 'buddyboss' ) ?></a>
		</div>

		<?php
	}

Changelog

Changelog
Version Description
BuddyPress 2.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.