$user_login, 'active' => 0, // Only look for inactive users ) ); // Check if the signup exists if ( ! empty( $signup_data['signups'] ) ) { $signup = $signup_data['signups'][0]; // Assuming the first result is correct // Activate the signup using BuddyPress' activation method $activation_result = BP_Signup::activate( array( $signup->signup_id ) ); if ( isset( $activation_result['activated'] ) && ! empty( $activation_result['activated'] ) ) { $activated_user = $activation_result['activated'][0]; // Log the successful activation error_log( "User successfully activated: " . $activated_user->ID ); // Automatically log in the user after activation wp_set_auth_cookie( $activated_user->ID, false, is_ssl() ); wp_set_current_user( $activated_user->ID ); error_log( "User logged in: " . $activated_user->ID ); // Redirect the user to their profile page bp_core_redirect( bp_core_get_user_domain( $activated_user->ID ) ); } else { error_log( "Error activating user: " . $signup->user_login ); } } else { error_log( "User signup not found or already activated: " . $user_login ); } } // Hook into the registration process add_action( 'bp_core_signup_user', function( $user_id, $user_login, $user_password, $user_email, $usermeta ) { wbcom_auto_activate_user( $user_login ); }, 10, 5 );