SimpleUsers
SimpleUsers copied to clipboard
Creating an admin
Hey, Great starter script here! I am wondering how to identify a user as "Admin" ?
In addition - how do we configure a forgot password with this script ?
I am also, attempting to create a "sign as user" - have you had luck with this ?
Hi.
Hey, Great starter script here! I am wondering how to identify a user as "Admin" ?
There is no "admin" user, but you could grant a user an attribute identifying them as an admin:
$simpleusers->setInfo('admin', 1);
And to test it:
if($simpleusers->getInfo('admin'))
{
// is admin
}
In addition - how do we configure a forgot password with this script ?
You would have to manually create a process to this and then use the method setPassword
. The script doesn't help you with all the mails and tokens necessary to do this in a secure way.
I am also, attempting to create a "sign as user" - have you had luck with this ?
Well, it wouldn't be hard to make, by adding a new method to the script:
public function loginAs($userId)
{
if($user = $this->getSingleUser($userId))
{
$_SESSION[$this->sessionName]["userId"] = $user["userId"];
$this->logged_in = true;
return true;
}
return false;
}
Awesome! Thanks for the support and comments, much appreciated on that.
Quickly, would that sign as user ... dump a url ? Sorry, I am not an advanced coder. Lol
No, you would have to create a route to a URL yourself, where you use that specific method.
Okay, I am extremely lost with that function - where would I push that into the code ? and how would I call it.