bp_members_action_activate_account()

Catches and processes account activation requests.

Description

Source

File: bp-members/screens/activate.php

function bp_members_action_activate_account() {
	if ( ! bp_is_current_component( 'activate' ) ) {
		return;
	}

	if ( is_user_logged_in() ) {
		return;
	}

	if ( ! empty( $_POST['key'] ) ) {
		$key = wp_unslash( $_POST['key'] );

	// Backward compatibility with templates using `method="get"` in their activation forms.
	} elseif ( ! empty( $_GET['key'] ) ) {
		$key = wp_unslash( $_GET['key'] );
	}

	if ( empty( $key ) ) {
		return;
	}

	$bp = buddypress();

	/**
	 * Filters the activation signup.
	 *
	 * @since BuddyPress 1.1.0
	 *
	 * @param bool|int $value Value returned by activation.
	 *                        Integer on success, boolean on failure.
	 */
	$user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );

	// If there were errors, add a message and redirect.
	if ( ! empty( $user->errors ) ) {
		bp_core_add_message( $user->get_error_message(), 'error' );
		bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
	}

	bp_core_add_message( __( 'Your account is now active!', 'buddyboss' ) );
	bp_core_redirect( add_query_arg( 'activated', '1', bp_get_activation_page() ) );

}

Changelog

Changelog
Version Description
BuddyPress 3.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.