Enhancing The new User registration Message On WordPress Multisite and BuddyPress to make it more informative for Site Admins
When a new User registers on a wordPress multisite/BuddyPress based site, the site admin gets a mail(of course if you have not disabled it in the options) and that mail is pretty useless, because it gives you the ip address and the username but nothing else.
As a Site Admin, I am always curious to know a little more about the user. So, the code below adds the user's email address and a view profile link to the email.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | remove_action( 'wpmu_new_user', 'newuser_notify_siteadmin' ); add_action( 'wpmu_new_user', 'newuser_notify_siteadmin_enhanced' ); function newuser_notify_siteadmin_enhanced( $user_id ) { if ( get_site_option( 'registrationnotification' ) != 'yes' ) { return false; } $email = get_site_option( 'admin_email' ); if ( is_email( $email ) == false ) { return false; } $user = new WP_User( $user_id ); // just make sure to not cause trouble when bp is disables. if ( function_exists( 'bp_core_get_user_domain' ) ) { $user_link = bp_core_get_user_domain( $user_id ); } else { // just making sure it works on normal wpms installs too. $user_link = network_admin_url( 'user-edit.php?user_id=' . $user_id ); } $options_site_url = esc_url( network_admin_url( 'ms-options.php' ) ); $msg = sprintf( __( 'New User: %1s Remote IP: %2s User email: %3s View Profile: %4s Disable these notifications: %5s' ), $user->user_login, $_SERVER['REMOTE_ADDR'], $user->user_email, $user_link, $options_site_url ); $msg = apply_filters( 'newuser_notify_siteadmin_enhanced', $msg, $user ); wp_mail( $email, sprintf( apply_filters( "new_user_registration_message_subject", __( 'New User Registration: %s' ) ), $user->user_login ), $msg ); return true; } |
You can put the above code in bp-custom.php or your theme's functions.php and It will work.
Screenshots:
here is the default registration message the site admin receives.
And here is what you get after putting that code.
And since the code is there, you can improve upon it. Like, add a direct link for marking spam or something else.
Hope It will be useful for a couple of you.
Nice. I made a ticket on BuddyPress, suggesting this be made part of the core in 1.3… seems to me that everybody would want this and you've already done all the work.
Hi Joseph,
Thanks for the comment. I will be happy to see it as a part of core. Just checked the ticket. let us hope the core devs include it in the 1.3 🙂
Hi brajesh,
I have got a problem with wordpress(buddypress) membership. When users register with a fake or wrong email address it gets stored in the db and eventually in the users list. As an admin my only option is to go check users list in dashboard and need to verify and delete the profile. spammers can be controlled using capcha, but i have got a lot of members who have registered with wrong mail ids and also many forget to activate their account. How to delete fake email profiles automatically(say may be based on email delivery) and how to delete unactivated users based on time(say a week).