Welcome Guest, Not a member yet? Register   Sign In
SHIELD: disable autonomous user registration
#2

This is what I use to create the SuperAdmin Account, it depends on what the default user group is set to in
app/Config/AuthGroups.php

PHP Code:
/**
 * createUser ()
 * -------------------------------------------------------------------
 *
 * @param string $userName
 * @param string $emailAddress
 * @param string $password
 */
public function createUser(string $userName ''string $emailAddress ''string $password ''): void
{
    // Get the User Provider (UserModel by default)
    $users auth()->getProvider();

    // Users record
    $user = new User([
        'username' => $userName,
        'email'    => $emailAddress,
        'password' => $password,
    ]);

    // Save the new user information
    $users->save($user);

    // To get the complete user object with ID, we need to get from the database
    $user $users->findById($users->getInsertID());

    // Add to default group
    $users->addToDefaultGroup($user);

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: SHIELD: disable autonomous user registration - by InsiteFX - 01-21-2024, 10:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB