Helping you Build Your Own Social Network!

Faster, better and easier!

How to make sidebar invisible?

(10 posts) (4 voices)

Tags:

No tags yet.


  1. How to make widget in sidebar only visible for logout user (& invisible for login user)?

    Thank's

    Posted 1 year ago #
  2. 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.

    Posted 1 year ago #
  3. 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)?

    Posted 1 year ago #
  4. 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...

    Posted 1 year ago #
  5. 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>'
    	)
    );
    Posted 1 year ago #
  6. 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?

    Posted 1 year ago #
  7. @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

    Posted 1 year ago #
  8. 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

    Posted 1 year ago #
  9. opposite of is_user_logged_in() = !is_user_logged_in()
    which is what I used in conditional statement above, notice the ! in second

    Posted 1 year ago #
  10. Thank's again Mercime, now it's work, This is easy way to solve my problem :)

    Posted 1 year ago #

Reply

You must log in to post.