Creating a New User With PHP on the Batoi RAD Platform
Requirements
- Access to the Batoi RAD platform.
- Familiarity with the platform's user interface.
Step-by-Step Guide to Adding a New Active User
Step 1: Create a User Data Array
Define an array $userData
with the required user information. For example:
$userData = [];
$userData['s_login_mode'] = 'SE';//Enum(‘GL’, ‘TW’, ‘SE’), [GL=Google, TW=Twitter, SE=Self]
$userData['s_fullname'] = 'Ross Geller';
$userData['s_email'] = 'ross.geller@hotmail.com';
$userData['s_username'] = 'ross.geller@hotmail.com';
$userData['s_mobile'] = '+18371044201';
$userData['s_password'] = 'Hello$123';
$userData['s_enablemfa'] = 'N';
$userData['s_role_id'] = 2;
To learn more about the database structure, please follow our help article Understanding the Database Structure of the Batoi RAD Framework.
Step 2: Instantiate User Object
Use the Batoi RAD Platform's \App\User
class to create a new user object. The example below illustrates this:
$oUser = new \App\User($this->runData);
To learn more about the array $this->runData
, Please follow our help article Understanding the $this->runData Array in Batoi RAD Framework..
Step 3: Insert User Data
Use the insert method of the user object to add the user. The response is stored in $this->runData[‘route’]
.
$this->runData = $oUser->insert($userData);
Step 4: Handle the Response
Check the response to determine if the user was added successfully.
Successful Registration
if ($this->runData['route']['alert'] === 'success') {
echo "User added successfully!";
}
Unsuccessful Registration
if ($this->runData['route']['alert'] === 'danger') {
echo "Error: " . $this->runData['route']['alert_message'];
}
Adding an Inactive User
To add an inactive user, include the ‘s_user_status’
parameter in the $userData array:
$userData['s_user_status'] = '0';//0 = Inactive, 1 = Active
This parameter sets the user status to inactive.
Conclusion
Follow these steps to add new users to your application on the Batoi RAD Platform using PHP. Customize the user data as needed and handle the responses for efficient user management.