BuddyPress: Email the Admin When a Member Activates
Emails the site admin when a new member activates their BuddyPress account, with a link to their profile.
Opens WPIDE on
Code
if ( ! function_exists( 'buddypress' ) ) {
return;
}
add_action( 'bp_core_activated_user', function ( $user_id ) {
$user = get_userdata( $user_id );
if ( ! $user ) {
return;
}
$profile = function_exists( 'bp_members_get_user_url' ) ? bp_members_get_user_url( $user_id ) : bp_core_get_user_domain( $user_id );
wp_mail(
get_option( 'admin_email' ),
sprintf( '[%s] New member: %s', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $user->display_name ),
sprintf( "%s (%s) has activated their account.\n\nProfile: %s", $user->display_name, $user->user_email, $profile )
);
} );
Notes
Fires once the member has clicked their activation link, so unconfirmed spam sign-ups are not reported.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.