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