How to make widget in sidebar only visible for logout user (& invisible for login user)?
Thank's
Faster, better and easier!
How to make widget in sidebar only visible for logout user (& invisible for login user)?
Thank's
hi Jack
use the conditional is_user_logged_in() where you are showing the widget area using dynamic_sidebar to call/not call it.
Otherwise, if you want to show hide a particular widget, the widget logic plugin will be a great help.
if is_user_logged_in() to make visible for login user login only, what the conditional action about to make visible only for user does'nt login(logout user)?
it's either off or on. If the user is logged in, it shows the widget. If the user isn't, then it hides it. I don't know php, but I think it's the ELSE that you're looking for.
If user logged in..
ELSE blah...
Or, you could also do it the other way around: if user is not logged in, show these widgets; otherwise, these widgets will show up in sidebar :
<?php if ( !is_user_logged_in() ) : ?>
<?php dynamic_sidebar( 'sidebar-visitor' ) ?>
<?php else : ?>
<?php dynamic_sidebar( 'sidebar' ) ?>
<?php endif; ?>
you would have to create another dynamic area in your functions.php like so
register_sidebars( 2,
array(
'name' => 'sidebar',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
)
array(
'name' => 'sidebar-visitor',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
)
);Thank's Symm2112 & mercime,
but I have error when add your dinamic area in my function.php :
Parse error: syntax error, unexpected T_ARRAY in /home/caretoc1/public_html/wp-content/themes/cosmicbuddy/functions.php on line 80
what's wrong?
@jack, my bad, there was duplication of sidebar functions. Should have asked what theme you're using and been more specific. Replace the register sidebars function I gave to this since you already have the other one
register_sidebars( 1,
array(
'name' => 'sidebar-visitor',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '<div class="clear"></div></div></div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3><div class="widget-content">'
)
);
place the above just before /* Load the AJAX functions for the theme */ in your functions.php
I'm using cosmicbuddy theme,
i'm still get error when i'm tried to paste your code:
Parse error: syntax error, unexpected T_ARRAY in /home/caretoc1/public_html/wp-content/themes/cosmicbuddy/functions.php on line 65
I hope that my welcome widget in cosmicbuddy theme only visible by user does'nt login, did you know other simple way, because i don't know about php?
did you know any conditional tags to make visible for user doesn't login but invisible for user login ( opposite from is_user_logged_in() )
thank you very much Mercime
opposite of is_user_logged_in() = !is_user_logged_in()
which is what I used in conditional statement above, notice the ! in second
Thank's again Mercime, now it's work, This is easy way to solve my problem :)
You must log in to post.