Support » Themes and Templates » Conditional Statement in Prologue

  • Hi

    Trying to have a conditional statement in Prologue theme that shows a different form if a user is not a member (or not logged in). This is my attempt but it’s not working:

    <?php
    	if( current_user_can( 'publish_posts' ) ) require_once dirname( __FILE__ ) . '/post-form.php';
    
    	} else {
    
    	if( current_user_can( 'level_0' ) ) require_once dirname( __FILE__ ) . '/banner-form.php';
    
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • popper

    (@julialasarte)

    Try with this:

    <?php if ( is_user_logged_in() )://check if user is logged in ?>
    <?php echo('hello, user');  // if he is, do stuff ?>
    <?php else: echo('hello, non user'); // if he isn't do other stuff?>
    <?php endif;?>

    It works for me in local. Of course, it just echoes “Hello, user/non-user”, but it’ll work with your forms too.

    Hope that helps

    Any ideas on how to make it work with my code from P2 as seen above?

    popper

    (@julialasarte)

    It’s the same, you just replace the echoes with the file you want to include:

    <?php if ( is_user_logged_in() )://check if user is logged in ?>
    				<?php include_once(dirname(__FILE__) . '/searchform.php');  // if he is, do stuff ?>
    				<?php else: include_once(dirname(__FILE__) . '/comments.php'); // if he isn't do other stuff?>
    				<?php endif;?>

    Above The logged in user would see the search form, and the user not logged in would see the comment form. Just replace searchform.php and comments.php with whatever you want to include in your case.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditional Statement in Prologue’ is closed to new replies.