wp_ajax_nopriv_{$action} WordPress Action Hook
The wp_ajax_nopriv_{$action} hook is triggered when an AJAX request is made by a user who is not logged in.
do_action( "wp_ajax_nopriv_{$action}" ) #
Fires non-authenticated Ajax actions for logged-out users.
Description
The dynamic portion of the hook name, $action
, refers to the name of the Ajax action callback being fired.
More Information
This hook is functionally the same as wp_ajax_{$action}, except the “nopriv” variant is used for handling AJAX requests from unauthenticated users, i.e. when is_user_logged_in() returns false.
Unlike wp_ajax_{$action} the ajaxurl javascript global property will not be automatically defined and must be included manually or by using wp_localize_script() with admin_url( ‘admin-ajax.php’ ) as the data.
See also wp_ajax_nopriv_{$_REQUEST[‘action’]}.
For more information, see Ajax Plugin Handbook on the new WordPress Developer Resource.
Source
File: wp-admin/admin-ajax.php
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |