[wp-trac] [WordPress Trac] #40477: REST API: Does NOT Trigger New User Notifications!
WordPress Trac
noreply at wordpress.org
Thu Apr 20 06:06:16 UTC 2017
#40477: REST API: Does NOT Trigger New User Notifications!
-------------------------------------------------+-------------------------
Reporter: mrahmadawais | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
Component: Users | Review
Severity: normal | Version: 4.7
Keywords: dev-feedback has-patch needs- | Resolution:
testing needs-unit-tests | Focuses: rest-api
-------------------------------------------------+-------------------------
Comment (by websupporter):
Yes, after doing some research, I think so too. Actually, I think, we
should use `'register_new_user'` like in ''user.php'':
{{{#!php
/** This action hook is documented in wp-includes/user.php **/
do_action( 'register_new_user', $user_id );
}}}
Ref.: https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/user.php#L2266
So, if someone dehooked the notice for the normal user registration (on
''wp-login.php''), the notice would also not be send via the REST API. But
maybe to register a user via the REST API can be seen as a new action
seperate of the user registration on ''wp-login.php'' in which case a new
action would be sensible.
Or, actually this convinces me more, we see a registration via the REST
API more aligned with the action in the wp-admin area. In this case, we
should probably use
`'edit_user_created_user'`.
{{{#!php
/** This action hook is documented in wp-admin/includes/user.php **/
do_action( 'edit_user_created_user', $user_id, $notify );
}}}
Ref.: https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/includes/user.php#L197
The `$notify` in the admin is populated via `$_POST`. If you mark the
checkbox to send the password to the new user `$notify` will be `'both'`,
otherwise it will be `'admin'`.
I was thinking about @TimothyBlynJacobs comment
> Ideally, this would also be controlled by a param in the POST body.
I think, this would be actually nice, since this means, we could easily
"Restify" the "Create New User"-form in the backend 1:1. But I can't
figure out a param which on the other side meets the criteria to be
general enough for a API param. Somehow I dislike a `notify` parameter
here.
Right now all params are somehow information about the new user (name,
email, locale etc.). A `notify`-param is not an additional information but
triggers an action and breaks with the existing schema.
Maybe someone comes up with a better idea or my concerns are somehow
mislead here, but if not:
A `notify`-param would switch the `'admin'`/`'both'`-behavior (if we go
with the current behavior). If we are not using such a param, we would
need to decide, which value `$notify` should have.
Coming from the original problem of this ticket, I think we should use
`both`, otherwise, we would miss the topic :)
> The notification for new WordPress users via email does NOT get
triggered.
This would be also inline with the standard behavior of
`wp_send_new_user_notifications()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40477#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list