I've hidden and created various profile fields using the following code:

function my_user_contactmethods($user_contactmethods) {

// You can get rid of ones you don't want

// And add any news ones. The array key is the meta key name, the text
// is however you want it labelled -- keep the key name the same as you have in gf map.

$user_contactmethods['I work for...'] = __('I work for...');

// etc for each field you want to appear

return $user_contactmethods;


add_filter( 'user_contactmethods', 'my_user_contactmethods');

I'm then trying to call the custom field using the following:

<?php echo get_user_meta($current_user->ID,'I work for...',true);?>

This doesn't show anything, can someone point me in the right direction?

  • Use Advanced Custom Fields plugin – lenden Jul 9 '14 at 20:01

Try instead

$user_contactmethods['work'] = __('I work for...');


<?php echo get_user_meta($current_user->ID,'work',true);?>

where the array index is 'work' instead of 'I work for...', i.e. lowercase and without any spaces.

  • I've just tried that, the info is getting inserted into the custom field but it still won't show on the front end. Is there another way to call it? – Rob Mar 4 '13 at 11:16
  • It works on my vanilla wp install, I just tested it. I checked the profile.php page for the current user, and inserted some value and saved it. Then added the code on single.php to test. – birgire Mar 4 '13 at 11:21
  • does this work for you: <?php echo "current userid:". $current_user->ID;?> – birgire Mar 4 '13 at 11:23
  • It's in the header.php file, so outside of the loop, that's probably why it's not working. – Rob Mar 4 '13 at 11:24
  • 1
    ok add global $current_user; before the code. – birgire Mar 4 '13 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.