Here is my code
$user_id = $_GET["user_id"];
$user = get_user_by('id',$user_id);
$balance = mycred_get_users_balance($user_id);
$user_info = get_userdata($user_id);
$first_name = $user_info->first_name;
$last_name = $user_info->last_name;
echo $first_name;
if ($balance > "0") {
mycred_subtract( 'Check-in',$user_id, -1, 'Checked in.' );
echo "Welcome " .$first_name." ".$last_name. "You are checked in.";
}
else{ echo "Welcome " .$first_name." ".$last_name;
echo "<br/>";
echo "You have a balance of " . $balance . ".";
echo "<br/>";
echo "Please purchase more credits at our website
I am trying to display the User first name and last name, this was working previously on my wordpress website, now the $user object is empty I'm quite sure because nothing is being echoed. I am able to parse the $user_id from the URL and echo it, but when I try to echo the $first_name, get nothing. I do get
Welcome You are checked in
Hence I know that the get_user_by is not working, the $user_id DOES exist in the database, I'm testing #1 which is my ID. I feel like it is something to do with a mobile optimization because we are scanning a QR code to redirect to this page and passing the user_id through the URL.
EDIT* I switched off JetPack smartphone optimization and got the functions working, except still no $first_name
Any ideas???