wp_send_user_request( int $request_id ): true|WP_Error
- Since
- 4.9.6
- Source
wp-includes/user.php:4901
Description
If the request is not already pending, it will be updated.
Compatibility
- WordPress
- since 4.9.6
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$request_idint- ID of the request created via wp_create_user_request().
Return value
true|WP_Error- True on success,
WP_Erroron failure.
Performance profile
How much work a call to wp_send_user_request() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Expensive
- Scaling
- Constant
- Instructions
- 18–145
- Plugin surface
- 3 hooks
- Called by
- 2
Sends mail via wp_mail().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 160.
Third-party callbacks on 'user_request_action_email_subject', 'user_request_action_email_content', 'user_request_action_email_headers' run inside this call, and their cost is not bounded by anything here.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()called directly - mailsends mail
wp_mail()called directly - querycontent query
get_post()one call below wp_send_user_request() - cacheobject cache
wp_cache_get()one call below wp_send_user_request() - serializeserialisation
maybe_unserialize()one call below wp_send_user_request()
Further down the call graph this can also reach transient. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 9 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_send_user_request() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 18 | absint(), wp_get_user_request(), __() |
empty($request) | 135 | absint(), wp_get_user_request(), get_locale(), switch_to_locale(), wp_generate_user_request_key(), wp_user_request_action_description(), wp_login_url(), confirmaction(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail() |
!empty($request) | 136 | absint(), wp_get_user_request(), switch_to_user_locale(), wp_generate_user_request_key(), wp_user_request_action_description(), wp_login_url(), confirmaction(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail() |
empty($request) | 137 | absint(), wp_get_user_request(), get_locale(), switch_to_locale(), wp_generate_user_request_key(), wp_user_request_action_description(), wp_login_url(), confirmaction(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale() |
!empty($request) | 138 | absint(), wp_get_user_request(), switch_to_user_locale(), wp_generate_user_request_key(), wp_user_request_action_description(), wp_login_url(), confirmaction(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale() |
empty($request) | 142 | absint(), wp_get_user_request(), get_locale(), switch_to_locale(), wp_generate_user_request_key(), wp_user_request_action_description(), wp_login_url(), confirmaction(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), __(), add_query_arg() |
!empty($request) | 143 | absint(), wp_get_user_request(), switch_to_user_locale(), wp_generate_user_request_key(), wp_user_request_action_description(), wp_login_url(), confirmaction(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), __(), add_query_arg() |
empty($request) | 144 | absint(), wp_get_user_request(), get_locale(), switch_to_locale(), wp_generate_user_request_key(), wp_user_request_action_description(), wp_login_url(), confirmaction(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale(), __(), add_query_arg() |
!empty($request) | 145 | absint(), wp_get_user_request(), switch_to_user_locale(), wp_generate_user_request_key(), wp_user_request_action_description(), wp_login_url(), confirmaction(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale(), __(), add_query_arg() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 160 | 18–145 | 4 | |
| 8.5 | 160 | 18–145 | 4 | |
| 8.4 | 160 | 18–145 | 4 | 15 fewer instructions than PHP 8.3 |
| 8.3 | 175 | 18–160 | 4 | |
| 8.2 | 175 | 18–160 | 4 | |
| 8.1 | 175 | 18–160 | 4 | |
| 7.4 | 175 | 18–160 | 4 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 3
3 hooks fire while wp_send_user_request() runs, in this order:
- apply_filters( user_request_action_email_subject )filterline 4960 (+59 into the body)
Filters the subject of the email sent when an account action is attempted.
- apply_filters( user_request_action_email_content )filterline 5005 (+104 into the body)
Filters the text of the email sent when an account action is attempted.
- apply_filters( user_request_action_email_headers )filterline 5035 (+134 into the body)
Filters the headers of the email sent when an account action is attempted.
Uses · 18
- absint()Converts a value to non-negative integer.
- wp_get_user_request()Returns the user request object for the specified request ID.
- __()Retrieves the translation of $text.
- switch_to_user_locale()Switches the translations according to the given user's locale.
- switch_to_locale()Switches the translations according to the given locale.
- get_locale()Retrieves the current locale.
- wp_generate_user_request_key()Returns a confirmation key for a user action and stores the hashed version for future comparison.
- wp_user_request_action_description()Gets action description from the name and return a string.
- add_query_arg()Retrieves a modified URL query string.
- wp_login_url()Retrieves the login URL.
- wp_specialchars_decode()Converts a number of HTML entities into their special characters.
- get_option()Retrieves an option value based on an option name.
Show all 18
- home_url()Retrieves the URL for the current site where the front end is accessible.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- sanitize_url()Sanitizes a URL for database or redirect usage.
- wp_mail()Sends an email, similar to PHP's mail function.
- restore_previous_locale()Restores the translations according to the previous locale.
- WP_Error::__construct()Initializes the error.
Used by · 2
- _wp_personal_data_handle_actions()Handle list table actions.
- _wp_privacy_resend_request()Resend an existing request and return the result.
Changelog
Introduced in 4.9.6. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$request_id retyped from string to int.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/user.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.