Support

Account

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; ?>
  • 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.