Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Accessing the id field using simpleauth
  • Hello, What is the best way to access the id field of the logged in user using simpleauth? When I try these:
    <code>
    $user = Auth::instance()->get_user_array(array('id')); $user = Auth:instance()->get_id();
    </code> $user is resolves to 'simpleAuth' Thanks in advance.
  • when i use
    Auth::get_user_id()
    
    it is show BadMethodCallException [ Error ]: Invalid method: Auth\Auth::get_user_id it should be
    $user = \Auth::instance()->get_user_id();
        $this->uid = $user[1];
    
  • You get that error if you have multiple instances active, in which case the static interface doesn't know which instance to use. I am using "$user = \Auth::get_user_id();" in Depot, and it works fine.
  • get_id() returns information about the loaded Auth drivers. Use Auth::get_user_id(). Note that that will return an array structure as well, as Auth supports multiple drivers, and you can be logged in using more then one (each having their own 'id' value). So you need to combine the info from get_id() which gives you the list of drivers with the results from get_user_id() to find the 'id' determined by the "simpleauth" driver.
  • Thanks! I was able to access the key. I plan to use ninjauth for social logins down the road, and can already see how juggling mutiple ids per user may be necessary. Cheers,
    David

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion