• This is the code I have and get_user_by seems to be returning an empty object

    global $this_player;
    $player_name = strtolower(str_replace(" ","",trim(str_replace(range(0,9),'',get_the_title($id)))));
    $this_player = get_user_by('slug', $player_name);
    if ( !$this_player ) die('No valid user found!');

    Now I can’t past the if statement, however if I manually replace $player_name with ‘nicename’ then it works, I have confirmed that $player_name is holding nicename so I am a little confused.

    Thanks

Viewing 1 replies (of 1 total)
  • Very weird, are you really sure that the variable $ player_name is coming up with the correct value?

    If inserting the name of the player, rather than the variable, the function works only remains me to believe that the problem is in the variable. Of one echo $ player_name to confirm that is returning everything right.

Viewing 1 replies (of 1 total)
  • The topic ‘get_user_by slug isn't working’ is closed to new replies.