User Role Changed notification at registration
-
A freshly registered user gets the ‘User Role Changed’ notification even before his email was confirmed.
Can this be limited to active users only?
Thank you!
-
Hi Ivan,
Thanks for your message.How are you setting an ‘active’ user? Are you using a plugin or a custom function?
Thanks,
JackHello Jack, thank you for replying.
I’ve just checked it both of the ways. Here is what I have:
1.1 The user fills the standard Registration Form [desired username and email only].1.2 A standard WordPress ‘Verify your account’ email is sent to the user requesting an email to be verified.
1.3 Together with ‘activation’ request a user also gets two notifications set in the ‘BNforWP’ plugin: ‘User Role Changed’ & ‘New User – Welcome Email’ notifications. Those notifications are sent before a user verifies his email. Both of the BNforWP emails have empty [user_firstname] and [user_lastname] shortcodes [since the user did not filled his name and surname yet].
I assume that the ‘User Role Changed’ notification is sent because a user is assigned as ‘Subscriber’ by WordPress.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Second variant of registration [at the same site]:
2.1 The user fills the Gravity Form [with, username, name, surname, email, passwords…]
2.2 The user gets registered after filling the Gravity Form with the help of “Gravity Forms User Registration Add-On”. The user is registered as a non-veryfied user – the ‘User Activation’ feature of the GF plugin is set to not ‘Enable user activation’.
2.3 The same issue occurs as described in 1.2 and 1.3
In this case the [user_firstname] and [user_lastname] shortcodes are also blank even though the Gravity Form plugin passed the name and surname values into the user profile.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My question is:
– can the plugin be limited to not send the notifications to the users who did not verified their email yet?p.s. This should be the default behaviour, I think… receiving ‘New User – Welcome Email’ notification before the email is verified is really confusing… as if the email was auto-verified…
Hi Ivan,
Thanks for clarifying this.Are you using multisite?
Thanks,
JackNo, Jack. Plain WordPress 4.4.1 running X Theme.
Jack, I’ve just sent you a link via http://www.voltronik.co.uk/contact/
Thank you.Hi Ivan,
I saw, thank you.WordPress doesn’t send out ‘Activation’ emails to users in single site installations so I’m not sure where this is coming from unless additional functionality introduced by a plugin.
I can confirm a bug where the ‘User Role Changed’ notification is also being triggered when a new user registers. I’ll look to get that fixed.
For clarity, the ‘Welcome Email’ gets sent at the same time as the ‘New User Registration – For User’ notification however, it is designed to be a follow-up email to this. Think of it this way: the ‘New User Registration – For User’ notification includes key login information, where the ‘Welcome Email’ notification tells the new user about the site, points them to the various links / sections they might be interested in, etc.
Hope this helps.
JackThank you, Jack.
By speaking about ‘user activation’ I meant the ’email verification’, – seeing a user as inactive since the user can not login to WordPress until his email is verified.
Is there a way to send a notification only after an email is verified?
p.s. Thank you for explanation about the ‘Welcome Email’ notification purpose. It sounds though that the ‘Welcome Email’ and ‘New User Registration – For User’ notifications are triggered at the same time [even with the different content]…
As a feature, it would be great if ‘User role change’ notifications could be specified to the specific role appointments.
For example, a user gets notification with editing details only if his appointed role is ‘editor’. ‘Authors’ at the same time. receive a different instructions – this would make your plugin an extra required WordPress feature, Jack.
Hi Ivan,
Conditional Notifications for users, categories, etc. is coming this year. It’s a big task and I have another add-on to get out before that. I think that’s what you’re looking for.With regards to ’email verification’, as far as i’m aware, a user doesn’t have to verify their email address when they’ve been registered in a vanilla WordPress installation. It sounds like another plugin is adding this functionality. Happy to be wrong and investigate though!
Jack
Jack, I’ve just installed fresh WordPress 4.4 installation.
The WordPress email verification works like this:
1. If ‘Anyone can register’ enabled in Admin > Settings > General a user sees ‘Register | Lost your password?’ links bellow the login form at /wp-login/2. When a user registers he inputs ‘username’ and ’email’ only. stating ‘Registration confirmation will be emailed to you.’
3. If the username and email are unique, WordPress registers a user in the ‘wp_users’ table of the WP database and outputs “Registration complete. Please check your email.”
3.1. The user DB record at this moment have non-empty ‘user_pass’ and ‘user_activation_key’ fields and looks like this:
INSERT INTO 'wpr_users' ('user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name') VALUES ('username', '$P$BXn0XEf8P9bqEHsdObA.7d3B.aztkY0', 'username', 'useremail@gmail.com', '', '2016-01-13 16:00:45', '1452700845:$P$BNeklCCqrPZx2dnxpPICvIiAFAv/tm0', 0, 'username');
4. The administrator gets a notification that states “New user registration on your site…”
5. The user gets an email that states:
Username: username To set your password, visit the following address: <http://domain.com/wp-login.php?action=rp&key=MnGyoNglnLEQW6cJx9l7&login=username> http://domain.com/wp-login.php
6. The link gets the user to the one-input form that requests: “Enter your new password below.”
7. On password change the WordPress outputs: “Your password has been reset. Log in”.
7.1 The user DB record at this moment have modified ‘user_pass’ field. But EMPTY ‘user_activation_key’ field and looks like this:
INSERT INTO 'wp_users' ('user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name') VALUES ('username', '$P$BaYtLPQZGXi5n1Ed5EoaZI/58eRznK.', 'username', 'useremail@gmail.com', '', '2016-01-13 16:00:45', '', 0, 'username');
8. The user can finally login to WordPress with the username and password.
The Notification Plugin, therefore simply have to check if the user has ‘user_activation_key’ empty before sending a ‘Role Changed’ notification.
Ah, I see! Thanks Ivan.
That functionality was added in WP 4.3 and i’ve had it on my roadmap to add better compatibility with that process for a little while now.I’ll make sure that the user role does the check that you suggested.
Thanks for spending the time working that out.
JackSure, Jack. I do appreciate your work over this wonderful plugin.
Thank you. Will wait for the updates.
Thank you.Jack, perhaps you can also differentiate the ‘Welcome Email’ and the ‘New User Registration – For User’ notifications.
And send one of those at the moment user sign-ups and the other one when the user account password is set [user’s email gets confirmed]?
Thank you.
IvanJack, in order not to send a ‘User role changed email‘ to the non-confirmed freshly registered users [with default WordPress role assigned] we have to simply add one line of code in send_user_role_chnaged_email() function in /wp-content/plugins/bnfw/includes/engine/class-bnfw-engine.php lines ~155:
Find:
$user = get_user_by( 'id', $user_id ); wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
Replace with:
$user = get_user_by( 'id', $user_id ); if ( $user->user_activation_key == '' ) wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
p.s. There is a typo in send_user_role_chnaged_email() function name.
Hi Ivan,
Thanks for taking the time to look at the code.I’ll take a look and do some testing. If all’s well, I’ll include it in the next release.
I’ll also look to improve the Welcome Email with your suggestion when I overhaul this area of functionality to better comply with WordPress 4.3 and above.Thanks again,
Jack
- The topic ‘User Role Changed notification at registration’ is closed to new replies.