Home › Forums › Front-end Issues › Conditional logic for user custom fields – author.php › Reply To: Conditional logic for user custom fields – author.php
Hi nicoloaversa! Try this:
<?php
// get current author object
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
$author_id = $curauth->ID;
$user_facebook = get_field('user-facebook', 'user_'.$author_id); // see https://www.advancedcustomfields.com/resources/how-to-get-values-from-a-user/
if( $user_facebook ): ?>
<h5><?php echo $user_facebook; ?></h5>
<?php else: ?>
// do something else
<?php endif; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.