How can I modify my following code to add some description text under the input fields? I tried modifying it as you can see with the facebook url field but the text shows up under the field label and not the actual input field —
function modify_contact_methods($profile_fields) {
// Add new fields
$profile_fields['address'] = 'Address';
$profile_fields['city'] = 'City';
$profile_fields['state'] = 'State';
$profile_fields['zipcode'] = 'Zip Code';
$profile_fields['phone'] = 'Phone Number';
$profile_fields['fax'] = 'Fax';
$profile_fields['gplus'] = 'Google+ URL';
$profile_fields['twitter'] = 'Twitter URL';
$profile_fields['facebook'] = 'Facebook URL <br /><span style="clear:both;">Ex: www.facebook.com/username</span>';
// Remove old fields
unset($profile_fields['aim']);
unset($profile_fields['yim']);
unset($profile_fields['jabber']);
return $profile_fields;
}
add_filter('user_contactmethods', 'modify_contact_methods');
Based on information gathered HERE and HERE; I was able to put something together.
First… abandon your first approach. It will add a field value, yes. But it will not allow you to add a descriptive field.
Instead, we need to create an entire new
table
tag in the structure that gets populated from WordPress. To do so, let’s use this function:That will define our new
tr
element, and populate it with the necessary structure. You may change the field label and description to suit your needs.NOTE: This will only create our new
tr
element, and place it at the bottom of the “About Yourself” section. In order to ‘place’ the newtr
element where we want (ie the “Contact Info”), we have to use a bit of jQuery:This code will take our new
tr
element, and add it BEFORE the “WEBSITE” field that is generated by WordPress.NOTE: See how we are hooking to
admin_head
here? We want to make sure this doesn’t run on every admin page. So, the first part of this code block will check the current page, and only run the code if we are on the profile page.Now… that’s great. Placement is Perfect!! But wait… now our data is not saving when we update the fields. Fret not!! We have another hook for that:
This will update the field, and store it in the user meta table. Then, whenever you need to access this value from your template; just use the
get_user_meta
function.