WordPress.org

Ready to get started?Download WordPress

Forums

Help with some PHP code (2 posts)

  1. mikelacroix
    Member
    Posted 2 years ago #

    Hello!

    Could anyone tell me what I'm doing wrong here?

    <?php
    $user_id = get_current_user_id();
      if ( $user_id == 38 ) {
    echo'';
    
    } else {
    echo '<?php
    	$single = is_single();
        	if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) :
        ?>
    
        <?php endif; ?>';
    }
    ?>

    I'm trying to get the code to return the dynamic sidebar for all users except for user 38, who will get nothing returned. I keep getting errors in the 'else' section. Any assistance would be remarkable!! :)

  2. Chris Fritz
    Member
    Posted 2 years ago #

    If you've registered your sidebar in your functions.php file, try this code, replacing SIDEBAR_NAME with whatever name you registered your sidebar with.

    <?php
    $user_id = get_current_user_id();
    if ( !($user_id == 38) ) {
    	dynamic_sidebar('SIDEBAR_NAME');
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic