user->create (method)

Return to Knowledgebase

Purpose

Creates a new UserSpice user and returns the id

Location

users/classes/User.php

Parameters

This function does not take any arguments

Example

user->create($fields = array()) (see below)

Further Documentation:

This is primarily an internal function, but there may be a use case for it in your own development. Please note that this does not automatically give the new user permissions, however it does return the new id, so you can do that separately. Also note that this does not do any checking to make sure this email/username does not exist. That should be done first.

$theNewId = $user->create(array(
'username' =>Input::get('username'),
'fname' => ucfirst(Input::get('fname')),
'lname' => ucfirst(Input::get('lname')),
'email' => Input::get('email'),
'password' => password_hash(Input::get('password', true), PASSWORD_BCRYPT, array('cost' => 12)),
'permissions' => 1,
'account_owner' => 1,
'join_date' => date('Y-m-d H:i:s'),
'vericode' => randomstring(15),
'vericode_expiry=>date("Y-m-d H:i:s",strtotime("+$settings->join_vericode_expiry hours",strtotime(date("Y-m-d H:i:s")))),
'oauth_tos_accepted' => true
));