Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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???

share|improve this question
    
Indent the line four spaces and you get a code block. (There is a Javascript tool-- look for {}) See: wordpress.stackexchange.com/editing-help –  s_ha_dum Mar 15 '13 at 21:57

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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