do_action( "wp_ajax_nopriv_{$action}" )

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.

Top ↑

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.

Top ↑


File: wp-admin/admin-ajax.php. View all references

do_action( "wp_ajax_nopriv_{$action}" );

Top ↑


Version Description
2.8.0 Introduced.

Top ↑

User Contributed Notes

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