Skip to content

Instantly share code, notes, and snippets.

@verygoodplugins
Last active September 27, 2023 11:11
Show Gist options
  • Save verygoodplugins/0ec8942f06c0fb781594913be93af519 to your computer and use it in GitHub Desktop.
Save verygoodplugins/0ec8942f06c0fb781594913be93af519 to your computer and use it in GitHub Desktop.
Sends API calls non-blocking during login.
<?php
/**
* Sends API calls non-blocking during login.
*
* This is useful if your CRM has a slow API, it will allow the user to log in
* without any noticable delay. However, if the API is offline or fails to process
* the request, no error will be logged and there will be no indication it failed.
*
* @param array $parsed_args The HTTP API request args.
*/
function set_login_to_async( $parsed_args ) {
if ( did_action( 'wp_login' ) ) {
$parsed_args['blocking'] = false;
}
return $parsed_args;
}
add_filter( 'http_request_args', 'set_login_to_async', 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment