0

I've used this code to show custom fields if they're filled in a post using Custom Field Suite Plugin

<?php if($cfs->get('whatliked')){?>
<?php echo $cfs->get('whatliked'); ?>
<?php   }?>

Now I need to have the same check for some custom profile fields I've added through functions.php

/* BEGIN Custom User Contact Info */
 function extra_contact_info($contactmethods) {
     unset($contactmethods['aim']);
     unset($contactmethods['yim']);
     unset($contactmethods['jabber']);
     $contactmethods['facebook'] = 'Facebook';
     $contactmethods['twitter'] = 'Twitter';
     $contactmethods['google+'] = 'Google+';
     $contactmethods['linkedin'] = 'LinkedIn';
     return $contactmethods;
 }
 add_filter('user_contactmethods', 'extra_contact_info');
 /* END Custom User Contact Info */

What is the code I need to add to my author.php to check if the facebook field has been filled and if "yes" then show and if "no" then hide...

P.s. Is there a way to post the code with linebreaks already in???

0

On an "author" page you can get a lot of the information you need with get_queried_object and additional information with get_user_meta. What you want (sounds like) should be in that second chunk of information.That is...

$author = $wp_query->get_queried_object();
$ameta = get_user_meta($author->ID);

var_dump($author,$ameta); // debugging

if(!empty($ameta['facebook'])) {
  var_dump($ameta['yim']); // debugging
}
// and so one for each contact method that you want to show

I am sure that is not how you want the information formatted but that should get you going.

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.