Hey @quix8 – Thank you very much for your message.
By default this is not possible, but you can surely make that work with some lines of code.
To help you out, I provided down below a snippet that you can post into your functions.php file of your theme.
What it does:
It will check if a custom meta value is set for the user login and if there isn’t one, it will fire the trigger and set that specific meta value for future checks.
How to make it work:
Once you pasted the code into the functions.php file, simply change the value of the $webhook_name
variable to the name of your added webhook URL.
That’s it, after it will work as expected.
Do let me know in case you have any further questions. ??
The code to paste:
add_filter( 'wpwhpro/admin/webhooks/is_valid_trigger_response', 'wpwh_fire_on_on_first_user_login', 20, 4 );
function wpwh_fire_on_on_first_user_login( $response, $webhook, $data, $args ){
$webhook_name = 'your-webhook-url-name'; //Add the webhook name of your webhook URL here
$webhook_integration = 'login_user';
$webhook_group_name = ( is_array($webhook) && isset( $webhook['webhook_name'] ) ) ? $webhook['webhook_name'] : '';
$webhook_url_name = ( is_array($webhook) && isset( $webhook['webhook_url_name'] ) ) ? $webhook['webhook_url_name'] : '';
if( $webhook_integration === $webhook_group_name && $webhook_url_name === $webhook_name ){
if( is_array( $data ) && isset( $data['ID'] ) ){
$user_id = $data['ID'];
$logged_in_before = get_user_meta( $user_id, 'wpwh_was_logged_in_before', true );
if( empty( $logged_in_before ) ){
$response['is_valid'] = true;
update_user_meta( $user_id, 'wpwh_was_logged_in_before', 'yes' );
} else {
$response['is_valid'] = false;
}
}
}
return $response;
}