#28: autocomplete_users_for_site_admins

The autocomplete_users_for_site_admins filter allows you to enable user auto-complete for non-super admins in Multisite.

It was added in 3.4.

It is evaluated in wp_ajax_autocomplete_user() in the wp-admin/includes/ajax-actions.php file.

autocomplete_users_for_site_admins accepts a single argument:

  1. bool true|false Whether to die() for non-super admin users. Default is false.

Example:

The following example would enable user auto-complete in Multisite for users with the promote_users capability.

View the code example on Gist.

#27: heartbeat_nopriv_send

The heartbeat_nopriv_send filter allows you to modify the Heartbeat response sent when no $_POST data is passed.

It was added in 3.6.

It is evaluated in wp_ajax_nopriv_heartbeat in the wp-admin/includes/ajax-actions.php file.

heartbeat_nopriv_send accepts 2 arguments:

  1. array|object $response The response object or array.
  2. string $screen_id The screen id

Example:

There is no example for this filter yet. Have an idea for one? Submit an example.

#26: heartbeat_nopriv_received

The heartbeat_nopriv_received filter allows you to modify the Heartbeat response data in no-privilege — that is, non-logged-in AJAX situations such as for use on the front-end.

It was added in 3.6.

It is evaluated in wp_ajax_nopriv_heartbeat() in the wp-admin/includes/ajax-actions.php file.

heartbeat_nopriv_received accepts 3 arguments:

  1. array|object $response The nopriv Heartbeat response.
  2. array $data An array of data passed via $_POST.
  3. string $screen_id The screen id.

Example:

The following example is based on a Heartbeat example Gist written by Jason Coleman and kindly suggested by jsternberg in the comments.

It modifies the $response value to return a ‘marco polo’ scenario showing the server “responding” to the AJAX call. Thanks to for the suggestion!

View the code example on Gist.