Thanks, in fact I use a similar function for showing “gender” and “self description” fields. There I can edit the template directly in PHP/HTML as it is portrayed in your link.
But I want to be able to use wp_get_user_contact_methods() in frontend and collect all available options there for a counter variable. This is only possible when they are actually saved in user_contactmethods.
I now ended up like this:
functions.php
function load_custom_wp_admin_scripts() {
// Admin CSS
wp_enqueue_style('ksv-admin-style', get_template_directory_uri().'/style-admin.css', array(), '1.0.0');
// Contact information jQuery Script
wp_enqueue_script('ksv-custom-admin', get_template_directory_uri().'/js/ksv-custom-admin.js', array ('jquery'), '0.0.1', true);
$translation_array = array(
'emailpublic_text' => __('E-mail address (public)', 'ksv'),
'facebook_text' => __('Facebook profile URL', 'ksv'),
'instagram_text' => __('Instagram profile URL', 'ksv'),
'pinterest_text' => __('Pinterest profile URL', 'ksv'),
'linkedin_text' => __('LinkedIn profile URL', 'ksv'),
'twitter_text' => __('Twitter profile URL', 'ksv'),
'tumblr_text' => __('Tumblr profile URL', 'ksv'),
'wikipedia_text' => __('Wikipedia profile URL', 'ksv'),
'youtube_text' => __('YouTube profile URL', 'ksv'),
'website_text' => __('Website URL', 'ksv'),
'soundcloud_text' => __('Soundcloud profile URL', 'ksv'),
'myspace_text' => __('Myspace profile URL', 'ksv')
);
wp_localize_script('ksv-custom-admin', 'additional_admin_info', $translation_array);
}
add_action('admin_enqueue_scripts', 'load_custom_wp_admin_scripts');
wp_localize_script() is necessary to create translatable text, that’s why in jQuery it says for example ‘additional_admin_info.emailpublic_text’ instead of just ‘E-mail (public)’. I’m working with at least two languages and my theme has its own language files, of course you could decide to leave out that $translation_array and wp_localize_script() part if you don’t use translations.
ksv-custom-admin.js
jQuery(document).ready(function() {
jQuery('tr.user-emailpublic-wrap input#emailpublic').after('<span class="cm-additional-text">'+additional_admin_info.emailpublic_text+'</span>');
jQuery('tr.user-facebook-wrap input#facebook').after('<span class="cm-additional-text">'+additional_admin_info.facebook_text+'</span>');
jQuery('tr.user-instagram-wrap input#instagram').after('<span class="cm-additional-text">'+additional_admin_info.instagram_text+'</span>');
jQuery('tr.user-linkedin-wrap input#linkedin').after('<span class="cm-additional-text">'+additional_admin_info.linkedin_text+'</span>');
jQuery('tr.user-myspace-wrap input#myspace').after('<span class="cm-additional-text">'+additional_admin_info.myspace_text+'</span>');
jQuery('tr.user-pinterest-wrap input#pinterest').after('<span class="cm-additional-text">'+additional_admin_info.pinterest_text+'</span>');
jQuery('tr.user-soundcloud-wrap input#soundcloud').after('<span class="cm-additional-text">'+additional_admin_info.soundcloud_text+'</span>');
jQuery('tr.user-tumblr-wrap input#tumblr').after('<span class="cm-additional-text">'+additional_admin_info.tumblr_text+'</span>');
jQuery('tr.user-twitter-wrap input#twitter').after('<span class="cm-additional-text">'+additional_admin_info.twitter_text+'</span>');
jQuery('tr.user-website-wrap input#website').after('<span class="cm-additional-text">'+additional_admin_info.website_text+'</span>');
jQuery('tr.user-wikipedia-wrap input#wikipedia').after('<span class="cm-additional-text">'+additional_admin_info.wikipedia_text+'</span>');
jQuery('tr.user-youtube-wrap input#youtube').after('<span class="cm-additional-text">'+additional_admin_info.youtube_text+'</span>');
});
style-admin.css (I also added some FontAwesome icons and additional styling but just to show the essential part):
.cm-additional-text {
padding-left: 20px;
font-style: italic;
}
So that’s how I’ve done it, it works for me and I just wanted to document my progress here in case someone else wonders how this can be achieved. I wanted to make sure that there is no easier or better solution for my scenario, thanks again. ??