Thank you @ihor !
This alternative solution worked for me.
No need for a shortcode, let’s create my own token instead.
Basically, I have a custom attribute called ‘type’ (vendor / customer), and I wanted to display a different message according to this attribute.
add_filter(
'hivepress/v1/emails/message_send',
function( $email ) {
$email['tokens']['custom_msg_by_type'] = "";
//recipient is known, it's a hivepress User, let's get user meta from its ID.
$user_type = get_user_meta($email['tokens']['recipient']->get_id(), 'hp_type', true);
if($user_type==115){//freelance
$email['tokens']['custom_msg_by_type'] = "Hello Freelance!"; //or whatever
}else if($user_type==116){//customer
$email['tokens']['custom_msg_by_type'] = "Hello Customer!";
}
return $email;
}
);
in message email template : use %custom_msg_by_type% to display the message.