• Resolved james-dg

    (@james-dg)


    Sounds like a pretty weird thing to ask but here is what I’m looking for…

    I have some custom fields on the user area in wordpress. These are then shown on the author page.
    What I have right now is users enter their facebook link and it will add a facebook icon to the page. The only problem is if a user doesn’t enter their url there is just a facebook icon there with no link.
    Is there a way to only show the image if a url has been added?
    Thanks 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • How are you calling the link & icon?

    Thread Starter james-dg

    (@james-dg)

    <a href="
    <?php $user = $curauth;
    
    // is there someone logged?
    if ($user->ID) {
    $value = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'FACEBOOKURL'));
    echo $value;
    }?>">
    <img src="<?php bloginfo('template_directory'); ?>/images/fbicon.png" alt="find us on facebook"/></a>

    Not sure If i’m even doing it right :’)

    Try:

    <?php if( $value && $value !='' ):?> <img src="<?php bloginfo('template_directory'); ?>/images/fbicon.png" alt="find us on facebook"/></a><?php endif;?>

    Thread Starter james-dg

    (@james-dg)

    Thank you Esmi 🙂
    I had to alter it slightly because it wouldn’t show the closing tag on the link.

    <a target="_blank" href="http://www.facebook.com/<?php $user = $curauth;
    if ($user->ID) {
    $value = cimy_uef_sanitize_content(get_cimyFieldValue($user->ID, 'FACEBOOKURL'));
    }?>
    <?php echo $value ?>">
    <?php if( $value && $value !='' ):?><img src="<?php bloginfo('template_directory'); ?>/images/fbicon.png" alt="Find us on facebook"/><?php endif;?>

    See it in action 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom fields check for input’ is closed to new replies.