Fetch and display tooltip value for specific field with PHP
-
Hi, I have figured out how to display a custom field on my register form on the user’s account page (/account/general) and make the field uneditable/not saveable from the front-end. On the register form for this particular field (whose meta key is
cust_acct_num), I have set some Help Text to show up in the UM tooltip. I am trying to get this same Help Text data to show up for the custom field in the account page. The code I have below adds the little info icon next to the label and displays the tooltip when hovering over it, but it’s not dynamic, so if I add another custom field to be displayed in the account page, it will show the same tooltip text for that other field as well.add_action('um_before_account_general', 'account_additional_disabled_fields', 100); function account_additional_disabled_fields(){ $custom_fields = [ "cust_acct_num" => 'Account Number', ]; foreach ($custom_fields as $k => $title) { $fields[ $k ] = array( 'title' => $title, 'metakey' => $k, 'type' => 'select', 'label' => $title, ); apply_filters('um_account_secure_fields', $fields, get_current_user_id()); $val = get_field($k, 'user_'.get_current_user_id() ) ? get_field($k, 'user_'.get_current_user_id() ) : ''; $html = '<div class="um-field um-field-text um-field-'.$k.' um-field-text um-field-type_text" data-key="'.$k.'"> <div class="um-field-label"> <label for="user_'.$k.'">'.$title.'</label> <span class="um-tip um-tip-w" original-title="Your account number"><i class="um-icon-help-circled"></i></span> <div class="um-clear"></div> </div> <div class="um-field-area"> <input disabled="disabled" class="um-form-field valid " type="text" name="'.$k.'" id="user_'.$k.'" value="'.$val.'" placeholder="" data-validate="" data-key="'.$k.'"> </div> </div>'; echo $html; } }This is the line above that I have added to display the info icon and tooltip
<span class="um-tip um-tip-w" original-title="Your account number"><i class="um-icon-help-circled"></i></span>
The topic ‘Fetch and display tooltip value for specific field with PHP’ is closed to new replies.