0

Hi so i'm triying to implement the UserFrosting script with the FreiChat script i've already implemented the chat, but at the time i want to pass the user id from UserFrosting it doesnt seems to apply the changes cause it keeps saying im a guest, now each script has it's own database and somehow i have to pass the Display name and the user id from the UserFrosting to the FreiChat i've tried the suggested code of both FreiChat wich says that i have to pass the user id of the current user by doing something like this

if(USER_IS_LOGGED_IN)
{ 
   $ses = LOGGED_IN_USERID; //tell freichat the userid of the current user

   setcookie("freichat_user", "LOGGED_IN", time()+3600, "/"); // *do not change -> freichat code
}
else {
    $ses = null; //tell freichat that the current user is a guest

    setcookie("freichat_user", null, time()+3600, "/"); // *do not change -> freichat code
} 

and i can pass the user_id from user frosting like this:

$loggedInUser->user_id

but doesnt seems to work, does anyone knows how to make it work?

alexw
  • 8,468
  • 6
  • 54
  • 86

1 Answers1

0

I haven't worked with FreiChat, but have you tried modifying their suggested code to use UserFrosting's functions? Something like:

if(isUserLoggedIn())    // isUserLoggedIn is UF's function to check whether or not a user is logged in
{ 
   $ses = $loggedInUser->user_id; //tell freichat the userid of the current user

   setcookie("freichat_user", "LOGGED_IN", time()+3600, "/"); // *do not change -> freichat code
}
else {
    $ses = null; //tell freichat that the current user is a guest

    setcookie("freichat_user", null, time()+3600, "/"); // *do not change -> freichat code
} 
alexw
  • 8,468
  • 6
  • 54
  • 86