The admin_post_nopriv_{$action} WordPress PHP action fires on a non-authenticated admin post request for the given action. The dynamic portion of the hook name, $action
, refers to the given request action.
Usage
add_action('admin_post_nopriv_{$action}', 'your_function_name'); function your_function_name() { // your custom code here }
Parameters
- None
More information
See WordPress Developer Resources: admin_post_nopriv_{$action}
Examples
Handling a contact form submission
In this example, we handle a contact form submission for non-authenticated users.
add_action('admin_post_nopriv_contact_form', 'process_contact_form'); function process_contact_form() { // your custom code for processing the contact form here }
Handling a newsletter subscription
In this example, we handle a newsletter subscription for non-authenticated users.
add_action('admin_post_nopriv_newsletter_subscribe', 'process_newsletter_subscribe'); function process_newsletter_subscribe() { // your custom code for processing the newsletter subscription here }
Handling a custom search request
In this example, we handle a custom search request for non-authenticated users.
add_action('admin_post_nopriv_custom_search', 'process_custom_search'); function process_custom_search() { // your custom code for processing the custom search request here }
Handling a comment submission
In this example, we handle a comment submission for non-authenticated users.
add_action('admin_post_nopriv_submit_comment', 'process_comment_submission'); function process_comment_submission() { // your custom code for processing the comment submission here }
Handling a file upload
In this example, we handle a file upload for non-authenticated users.
add_action('admin_post_nopriv_file_upload', 'process_file_upload'); function process_file_upload() { // your custom code for processing the file upload here }