MemberPress: Email the Admin About New Members
Sends you a short email with the member's name, email and membership as soon as someone completes a MemberPress sign-up.
Opens WPIDE on
Code
if ( ! class_exists( 'MeprUser' ) ) {
return;
}
add_action( 'mepr-event-transaction-completed', function ( $event ) {
$txn = $event->get_data();
$user = get_userdata( (int) $txn->user_id );
// Only first purchases of a membership, not renewals.
if ( ! $user || get_user_meta( $user->ID, 'wpide_mepr_notified_' . (int) $txn->product_id, true ) ) {
return;
}
update_user_meta( $user->ID, 'wpide_mepr_notified_' . (int) $txn->product_id, time() );
wp_mail(
get_option( 'admin_email' ),
sprintf( 'New member: %s joined %s', $user->display_name, get_the_title( (int) $txn->product_id ) ),
sprintf( "Name: %s\nEmail: %s\nMembership: %s\nProfile: %s", $user->display_name, $user->user_email, get_the_title( (int) $txn->product_id ), admin_url( 'user-edit.php?user_id=' . $user->ID ) )
);
} );
Notes
Complements MemberPress's own admin emails with a plain summary you can forward or filter.
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.