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

View on Trac

Changelog

Version Description
2.8.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/wp_ajax_nopriv_action