Skip to content

WordPress 4.3.1 changed wp_new_user_notification() again, conflicting s2member v150827 #732

@bridgeport

Description

@bridgeport

The change in WordPress 4.3.1 wp_new_user_notification() pluggable function effectively undoes the fix in the latest s2member version, which was extensively discussed in issue #689

v150827
(s2Member/s2Member Pro) WordPress v4.3 Compat./Bug Fix This release of s2Member alters the way New User Notification Emails are sent, and in how they should be formatted in WordPress v4.3+.

The New User Notification Email is now sent (to a user) only if they did not set a Custom Password during their registration; i.e., only if they need this email to set their password for the first time. In short, s2Member now follows the same approach used by WordPress v4.3+.

Settings to reproduce:

General Options > Email Configuration > New User Email Configuration > No (default, use WordPress defaults)
General Options > Registration/Profile Fields & Options > Allow Custom Passwords During Registration > Yes

Following a checkout where a user chooses their own password, the following is emailed to the user:

Email subject:

[Site Name] Your username and password info

Email body:

Username: johndoe

To set your password, visit the following address:

https://example.com/wp-login.php?action=rp&key=zbbbtvqzynH4fgaqgy6m&login=johndoe

https://example.com/wp-login.php

If a user is setting their own password upon registration, the above obviously shouldn't be sent.

The pluggable wp_new_user_notification() function arguments changed again, as documented here:
Passwords: Deprecate second parameter of wp_new_user_notification().

Version 4.3 function with two arguments:

/**
 * Email login credentials to a newly-registered user.
 *
 * A new user registration notification is also sent to admin email.
 *
 * @since 2.0.0
 * @since 4.3.0 The `$plaintext_pass` parameter was changed to `$notify`.
 *
 * @param int    $user_id User ID.
 * @param string $notify  Whether admin and user should be notified ('both') or
 *                        only the admin ('admin' or empty).
 */
function wp_new_user_notification( $user_id, $notify = '' ) {}

Version 4.3.1 function with three arguments (middle argument deprecated):

/**
 * Email login credentials to a newly-registered user.
 *
 * A new user registration notification is also sent to admin email.
 *
 * @since 2.0.0
 * @since 4.3.0 The `$plaintext_pass` parameter was changed to `$notify`.
 * @since 4.3.1 The `$plaintext_pass` parameter was deprecated. `$notify` added as a third parameter.
 *
 * @global wpdb         $wpdb      WordPress database object for queries.
 * @global PasswordHash $wp_hasher Portable PHP password hashing framework instance.
 *
 * @param int    $user_id    User ID.
 * @param null   $deprecated Not used (argument deprecated).
 * @param string $notify     Optional. Type of notification that should happen. Accepts 'admin' or an empty
 *                           string (admin only), or 'both' (admin and user). The empty string value was kept
 *                           for backward-compatibility purposes with the renamed parameter. Default empty.
 */
function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {}

I assume there's a possibility that WordPress will eventually remove the second $deprecated argument, which would reintroduce this issue, unless s2member were modified to expect the third $notify argument to always be the last argument.

Thanks.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions