Skip to content
Docs
Get RestroPress

Action

rpress_checkout_user_error_checks

Updated
On this page

Fires after the checkout user has been resolved so extensions can validate user-dependent fields.

Runs in rpress_process_purchase_form() after the checkout login form (when submitted) has been processed and the purchase user has been determined, and before the function checks for errors and stops. Use it for checks that need the logged-in or newly resolved user. Call rpress_set_error() to block the order.

Parameters#

ParameterTypeDescription
$userarray|boolThe purchasing user data array, true for AJAX validation requests, or false when no user could be resolved.
$valid_dataarray|falseValidated data from rpress_purchase_form_validate_fields(), or false.
$dataarraySanitized copy of $_POST.

Example#

add_action( 'rpress_checkout_user_error_checks', 'my_block_flagged_users', 10, 3 );
function my_block_flagged_users( $user, $valid_data, $data ) {
	if ( is_array( $user ) && ! empty( $user['user_id'] ) && get_user_meta( $user['user_id'], 'my_blocked', true ) ) {
		rpress_set_error( 'my_blocked', __( 'Orders from this account are disabled.', 'my-plugin' ) );
	}
}

Notes#

Fires on both the AJAX validation request and the final submission.

Source#

Fired from:

  • includes/process-purchase.php (line 135), in rpress_process_purchase_form()

See also#

Was this page helpful?