Closed omarghalib closed 2 years ago
Hi @omarghalib , do you know which version of the plugin are you using?
Hi @dalenguyen , I'm using version 3.8.0
Hi @omarghalib, if you are using that version. The firebase uid can be retrieved using this.
get_user_meta($user_id, 'firebase_uid', true);
Thank you @dalenguyen , but I tried it like this:
$user_id_txt = get_user_meta($user_id, 'firebase_uid', true);
echo $user_id_txt;
echo $user_id;
and it's not echoing anything
Hi @omarghalib, can you send a snapshot of how the user looks like in the WordPress dashboard?
Did the user log in via the plugin authentication shortcode?
Hi @dalenguyen ,
I'm showing firebase login UI using:
echo do_shortcode("[firebaseui_web redirect='/shop/account' ][/firebaseui_web]");
echo do_shortcode("[firebase_logout redirect='/shop/account' button_text='Sign Out'][/firebase_logout]");
And logging in but then I can't get the uid, I can echo it though, using:
echo '<input type="text" name="userID" value="will-be-generated" class="getFirebaseUid">';
But I need to save it to variable
Thank you @dalenguyen , but I tried it like this:
$user_id_txt = get_user_meta($user_id, 'firebase_uid', true);
echo $user_id_txt;
echo $user_id;
and it's not echoing anything
Which $user_id that you used for testing? Does it show the number of the user?
Can you send me a picture of the user in the WordPress dashboard after they sign in?
Hi @dalenguyen
I'm not using wordpress authentication in this,
The user id I get with this:
echo '<input type="text" name="userID" value="will-be-generated" class="getFirebaseUid">';
is the firebase's user that's logged-in . I need to save that id into a variable
So, in this case, you can try this custom script.
const waitForFirebase = setInterval(() => {
if (typeof firebase !== 'undefined' && firebase.apps.length) {
firebase.auth().onAuthStateChanged(async (user) => {
// trigger functions after user is logged in
if (user) {
// User logged in already or has just logged in.
console.log(user.uid)
}
})
clearInterval(waitForFirebase)
}
}, 1000)
Thank you so much @dalenguyen :D It worked
Awesome. I'm glad :D
Hi, I'm trying to get the user id of logged-in firebase user and save it to a php variable, how can I do that?