Hmmm....Site categories plugin.... display page for logged in users only

I see that this plugin displays on the main blog. I only want logged in users to be able to view the categories.
I tried [loggedin] shortcode but there is nothing to wrap it around.
I tried Page Restrict plugin, but the categories still display.
I can't use Membership plugin bc not all members of the network are users of the main blog(1).
I can't use Privacy Plugin to require all users to have password for the main site bc I want non logged in users to be able to view it.
There is no shortcode yet.
Any other suggestions on how I can only let logged in users see this content?

  • aristath
    • Recruit

    Hello there @Atlanta, I hope you're well today!
    You'll have to do some custom coding to do that...
    Try adding this in your theme's functions.php file:

    if ( !is_user_logged_in() && $_SERVER['PHP_SELF'] == '/site-categories' ) {
    	wp_redirect( home_url() );

    replace site-categories with the actual url of your site categories page and let me know if that works for you...


  • Atlanta
    • Syntax Hero

    @aristath. Wow, Athens, Greece. I'm jealous!

    I tried

    if ( !is_user_logged_in() && $_SERVER['PHP_SELF'] == '/site-categories' ) {
    	wp_redirect( home_url() );

    and also

    if ( !is_user_logged_in() && $_SERVER['PHP_SELF'] == '' ) {
    	wp_redirect( home_url() );


    if ( !is_user_logged_in() && $_SERVER['PHP_SELF'] == '' ) {
    wp_redirect( 'http:/', 301 ); exit;

    but the page still showed and no redirect happened.


  • Paul
    • The Green Incsub


    I'm about to release an update to Site Categories and wanted to check if there is something I can add to make this easier for you to manage. Maybe some filter that will allow you to call your own function to check the user and redirect if needed.

  • Atlanta
    • Syntax Hero

    @Paul Thanks for asking.

    Something like they do with Buddypress when you want to install it on another site
    define ( 'BP_ROOT_BLOG', $blog_id );
    define ( 'BP_ROOT_BLOG', 3 );


    A shortcode to display site categories in a subsite will be wonderful.
    And some way to block the main site categories page from showing.
    Otherwise if I set the page to private then the shortcode may not work if it directs back to the main page.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.