• Hello, I need help with some php. I cannot find it anywhere or I’m searching wrong. I’m working on a template that I need a statement to show up only when a user is logged in and on a specific page. I can get either one right. But I struggle with the combination. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • OK, if you show us the if statement you are using im sure we can help.

    Why don’t you simply use a plugin like members or groups?

    Thread Starter lazyym

    (@lazyym)

    I plan to use:

    <?php
    if ( is_user_logged_in() ) {
    echo ‘My content’;
    }

    and then I need it ONLY on specific pages.

    if( is_page( array( ‘mypage’, ‘myotherpage’ ) )

    }
    ?>

    It is actually on a template page inside of a plugin already….

    Oh right so you need to use &&.

    if ( is_user_logged_in() && is_page( array( ‘mypage’, ‘myotherpage’ ) ) ) {
    echo ‘My content’;
    }
    Thread Starter lazyym

    (@lazyym)

    Thanks Simon,

    I’m still not able to get it to work for some reason. I only have the one page for now but will ad more. This particular page is the home page if that matters.

    Here is the complete code I have in that php page.

    <?php if (is_user_logged_in() && is_page( array( ‘community’ ) ) ) {
    echo ‘test’;} ?>

    Is this correct?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Basic php help’ is closed to new replies.