Support » Themes and Templates » Help with some PHP code

  • mikelacroix

    (@mikelacroix)


    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!! 🙂

Viewing 1 replies (of 1 total)
  • Chris Fritz

    (@chrisvfritz)

    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');
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Help with some PHP code’ is closed to new replies.