• pixelboutiqueuk

    (@pixelboutiqueuk)


    In the dashboard, under the user profile, I have added some settings for authors to add social media links which will appear on the author.php page.

    If a section isn’t complete, for example if they don’t enter their facebook URL, but enter their Twitter, how do I stop the facebook section showing up in the author.php page but still showing the twitter section?

    I assume this is some if codex but I have no idea what and can’t figure it out.

    If someone could help, that would be fantastic.

    Thanks

    Leanne

Viewing 6 replies - 1 through 6 (of 6 total)
  • Michael

    (@alchymyth)

    I have added some settings for authors to add social media links which will appear on the author.php page.

    any suggestions to your question will possibly depend on what code you are using for that.

    please post your code.

    kobashicomputing

    (@kobashicomputing)

    This forum “How-To and Troubleshooting” is for standard WordPress use, not software coding.

    But to answer your question, doesn’t this involve checking to see if the fetched database data field is empty? If it is, then don’t generate the HTML for the section. And if you choose to generate it, then simply hide it with CSS.

    Thread Starter pixelboutiqueuk

    (@pixelboutiqueuk)

    Hi Michael,

    This is my functions.php code:

    // ADDITIONAL AUTHOR PROFILE SETTINGS
    function my_new_contactmethods( $contactmethods ) {
    
    // Add Twitter
    $contactmethods['twitter'] = 'Twitter';
    
    //add Facebook
    $contactmethods['facebook'] = 'Facebook';
    
    // Add Instagram
    $contactmethods['instagram'] = 'Instagram';
    
    // Add Pinterest
    $contactmethods['pinterest'] = 'Pinterest';
    
    return $contactmethods;
    }
    
    add_filter('user_contactmethods','my_new_contactmethods',10,1);

    and this is what I have in my author.php page:

    <h2>Social homes</h2>
    <p>
    <a href="<?php echo $curauth->twitter; ?>">Twitter</a><br>
    <a href="<?php echo $curauth->facebook; ?>">Facebook</a><br>
    <a href="<?php echo $curauth->instagram; ?>">Instagram</a><br>
    <a href="<?php echo $curauth->pinterest; ?>">Pinterest</a>
    </p>
    Michael

    (@alchymyth)

    you could for example try:

    <?php if( isset( $curauth->facebook ) ) { ?>
        <a href="<?php echo $curauth->facebook; ?>">Facebook</a><br>
    <?php } ?>

    etc

    Thread Starter pixelboutiqueuk

    (@pixelboutiqueuk)

    Thanks for that Michael.

    It still brought up the facebook link though, even though it wasn’t entered in the settings. It just links to the author page…?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    If the Facebook link isn’t entered into the settings, what does this output:

    $curauth->facebook

    ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to hide sections that are not complete in the user profile’ is closed to new replies.