How to get placeholder text in Custom Field in A+


I am trying to get some placeholder text in the the A+ appointment confirmation fields.

I have successfully created a new field, which syncs back and forth with the users' field in their profile. I would like for there to be a placeholder text in the custom field in the Appointment confirmation section. (For new users who have not updated their profiles yet)

Please let me know how that could be accomplished.


  • Judah

    Hey @Vinod Dalvi,

    Have you created that custom field using Appointments+ additional custom fields module?

    Yes the field has been created already (Backup Video Service)

    Do you want to add placeholder text only in this created custom field on in all?

    I would like to be able to place some placeholder text in this custom field and potentially in the other fields but for now just this newly created field.

    I will send you the details on how to access the appt pages. You need to be a logged in user to achieve that. Will send shortly.


  • Vinod Dalvi

    Hi Judah,

    You can try achieving this by using the following code in the functions.php file of your child theme.

    Change the text "This is placeholder text" in the following code to whatever you want to use as a placeholder.

    function app_custom_to_clean_name ($label) {
    		$clean = preg_replace('/[^-_a-z0-9]/', '', strtolower($label));
    		if (empty($clean)) $clean = substr(md5($label), 0, 8);
    		return $clean;
    add_filter('app_additional_fields', 'app_custom_inject_additional_fields');
    function app_custom_inject_additional_fields ($form) {
            global $current_user, $appointments;
    		$this_data = $appointments->options;
            $fields = !empty($this_data['additional_fields']) ? $this_data['additional_fields'] : array();
            if (empty($fields)) return $form;
            foreach ($fields as $field) {
                $label = esc_html($field['label']);
                $clean = app_custom_to_clean_name($field['label']);
                $id = "appointments-{$clean}" . md5(serialize($field));
                $type = esc_attr($field['type']);
                $user_meta_value = get_user_meta( $current_user->ID, 'app_' . $clean, true );
                $placeholder_text = "This is placeholder text";
                $value = $user_meta_value ? $user_meta_value : ('checkbox' == $type ? 1 : '');
                $form .= "<div class='appointments-field appointments-{$clean}-field'>" .
                    '<label for="' . $id . '"><span>' . $label . '</span></label>' .
                    "<input type='{$type}' id='{$id}' class='appointments-field-entry appointments-{$clean}-field-entry' data-name='{$clean}' value='{$value}' placeholder='{$placeholder_text}' />" .
            return $form;

    Best Regards,
    Vinod Dalvi

  • Judah

    Hey @Vinod Dalvi,

    This is working. Thank you!

    Is there a way for this not to override the code that I wrote that automatically displays/enters the information that is already in the users' profile?
    As of now the placeholder text is always displayed, even though the user may have that information in their profile.

    Meaning, if the user has no information in their account for that field, then the placeholder text is displayed. But if the user does have information in their account for that field, the information is displayed. (currently works without the code you provided).

    Please let me know,

  • Judah

    Hey @Vinod Dalvi & @Ashok,

    Thank you for trying to help me resolve this issue.

    The code that Vinod supplied did indeed add in a placeholder text but due to other customization's (syncing the info back and forth with the database), I could not use it.

    I got around this by just changing the entire field name to be a bit more descriptive so the user is aware of what information to place there.

    Thanks again!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.