Skip to content

Commit 8ddfe96

Browse files
Apply the patch
1 parent 45cf478 commit 8ddfe96

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,23 @@ public function create_item( $request ) {
647647
}
648648
}
649649

650+
/**
651+
* Filters the type of notification sent upon new user registration.
652+
*
653+
* This filter allows customization of the notification type when a new user is created via REST API.
654+
*
655+
* @param string $notify Determines who gets notified. Accepts:
656+
* - 'admin' (default) or an empty string: Notify only the site administrator.
657+
* - 'user': Notify only the new user.
658+
* - 'both': Notify both admin and user.
659+
* - 'false': Disable notifications entirely.
660+
* @param int $user_id User ID.
661+
*/
662+
$notify = apply_filters( 'rest_wp_user_created_notification', $notify = 'admin', $user_id );
663+
if ( $notify && 'false' != $notify ) {
664+
wp_new_user_notification( $user_id, null, $notify );
665+
}
666+
650667
$user = get_user_by( 'id', $user_id );
651668

652669
/**

0 commit comments

Comments
 (0)