do_action( “wp_ajax_nopriv_{$action}” )

In this article

Fires non-authenticated Ajax actions for logged-out users.


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.


do_action( "wp_ajax_nopriv_{$action}" );



User Contributed Notes

You must log in before being able to contribute a note or feedback.