Email Confirmation - using name instead of ID for CLIENT tag

Hi
When sending out emails for confirmation, can you tell me how the email can be made to include the First and Last name instead of the User Name [John Doe instead of userxyz, where userxyz being the login name the client chose]

Thanks
Vandana

  • Vinod Dalvi
    • WP Unicorn

    Hi Vandana,

    I hope you are well today and thank you for your question.

    To cahcieve this try adding the placeholders FIRST_NAME and LAST_NAME in the Confirmation email Message and add the following code in the functions.php file of your child theme.

    function my_app_expand_first_name ($msg, $app) {
    	if (empty($app->user))
    		return $msg;
    
    	$first_name = get_user_meta($app->user, 'first_name', true);
    	$msg = preg_replace('/FIRST_NAME/', $first_name, $msg);
    
    	$last_name = get_user_meta($app->user, 'last_name', true);
    	$msg = preg_replace('/LAST_NAME/', $first_name, $msg);
    
    	return $msg;
    }
    add_filter('app_confirmation_message', 'my_app_expand_first_name', 10, 2);
    // add_filter('app_notification_message', 'my_app_expand_first_name', 10, 2);
    // add_filter('app_reminder_message', 'my_app_expand_first_name', 10, 2);

    Best Regards,
    Vinod Dalvi

    • vandana
      • Design Lord, Child of Thor

      Hi Vinod
      As always THANK YOU. Your code works perfectly as expected.

      While I have your attention, can you please tell me how to force the plugin to send email (same as the one sent when Admin moves appointment status to 'Removed') when a client cancels an appointment on the front end.

      Thanks
      Vandana

  • vandana
    • Design Lord, Child of Thor

    Hi Vinod
    As always THANK YOU. Your code works perfectly as expected.

    While I have your attention, can you please tell me how to force the plugin to send email (same as the one sent when Admin moves appointment status to 'Removed') when a client cancels an appointment on the front end.

    Thanks
    Vandana

  • Predrag Dubajic
    • Support

    Hi @vandana,

    My apologies for the long overdue on this thread.

    By default a admin doesn't receive notification of a cancelled appointment, but you should be able to enable it by adding this code snippet in functions.php file of your theme:

    function my_app_email_on_appointment_cancelled ($app_id) {
    	global $appointments;
    	$to = $appointments->get_admin_email();
    	wp_mail($to, 'An appointment has been cancelled', "An appointment with ID {$app_id} has just been cancelled.");
    }
    add_action('app-appointments-appointment_cancelled', 'my_app_email_on_appointment_cancelled');

    Let us know if this worked for you.

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.