Support » Plugin: Widget Logic » [Plugin: Widget Logic] user logged in syntax help

  • Resolved mridl200


    Hey guys,
    I am trying to script a small amount of php to change a link based on if the user is logged in or not.

    What I have is :
    if ( is_user_logged_in() ) {
    echo ‘Welcome, registered user!’;
    } else {
    echo ‘Welcome, visitor!’;

    However I dont really understand how widget logic works. When I place this code in my footer widget any text from that widget is removed and nothing is shown. Ive tried changing the settings to load after all php has been loaded since is_user_logged_in() is part of a different php script but still did not work.
    Any help is appreciated, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor alanft


    If you put


    as the Widget Logic for a widget, that widget will only appear if the user is logged in. What is displayed in the widget is not controlled by widget logic. So you could e.g. have 2 ‘text’ widgets, one with is_user_logged_in() and one with !is_user_logged_in(), where ! means ‘NOT the case that’.

    Hope that helps

    That makes perfect sense. Thank you for clearing that up for me.
    I ended up making the two different text widgets like you suggested with
    is_user_logged_in() displaying a different link than when a user is logged out as I originally intended to make.

    Thanks again.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Widget Logic] user logged in syntax help’ is closed to new replies.