• Resolved robthirlby

    (@robthirlby)


    I’m sure this is a really silly question but why does this code not do what I expect. The if statement is never true even though the echo shows both $me and $name can be “admin”.

    $mypod = pods('user');
    	$me=do_shortcode('[userinfo field="user_login"]');
      $mypod->find('name ASC'); 
    
    while ( $mypod->fetch() ) {
         $name= $mypod->field('name');
    	if($name == $me) {
        echo "This is an echo statement in loop/$me/$name/<br>";}
    
        echo "This is an echo statement after loop /$me/$name/<br>";
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Try:

    $user = false;
    
    if ( is_user_logged_in() ) {
        $user = get_userdata( get_current_user_id() );
    }
    
    // also consider switching to this line for $name
    $name = $mypod->field( 'user_login' );
    
    // then in your loop, switch the if statement with this check
    if ( !empty( $user ) && $name == $user->user_login ) )
    Thread Starter robthirlby

    (@robthirlby)

    Many thanks for your time Scott.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘meta shortcodes problem in page template’ is closed to new replies.