WordPress.org

Ready to get started?Download WordPress

Forums

if logged in (5 posts)

  1. Tom555444
    Member
    Posted 9 months ago #

    I put the following into the text widget:
    <?php if ( is_user_logged_in() ) {
    [standout-css3-button href="<?php echo wp_logout_url( get_permalink() ); ?>"]Logout[/standout-css3-button]
    } else {
    [standout-css3-button href="/#login-box"]Login[/standout-css3-button]
    }
    ?>

    It shows up like this on my website (where it says (Login) is where my login button is and it works fine):
    Logout } else { (Login) } ?>

    I have put 'add_filter('widget_text', 'do_shortcode')' into the functions.php file for my theme so that short codes work in widgets.

  2. Tara
    Member
    Posted 9 months ago #

    What is the question?

  3. Kentaro Fischer
    Member
    Posted 9 months ago #

    Hi Tom,

    See if this code works for you:

    <?php if ( is_user_logged_in() ) {
    do_shortcode( '[standout-css3-button href="' . wp_logout_url( get_permalink() ).'"]Logout[/standout-css3-button]');
    } else {
    do_shortcode('[standout-css3-button href="/#login-box"]Login[/standout-css3-button]');
    }
    ?>

  4. Tom555444
    Member
    Posted 9 months ago #

    Thanks for your help!

  5. Kentaro Fischer
    Member
    Posted 9 months ago #

    My pleasure! Glad it was helpful.

Reply

You must log in to post.

About this Topic