Jump to content

How to create a new Employee from Php code ?


aymeric69001

Recommended Posts

From the install:

$employee = new Employee();
$employee->id = 1;
$employee->force_id = true;
$employee->firstname = Tools::ucfirst($data['admin_firstname']);
$employee->lastname = Tools::ucfirst($data['admin_lastname']);
$employee->email = $data['admin_email'];
$employee->setWsPasswd($data['admin_password']);
$employee->last_passwd_gen = date('Y-m-d h:i:s', strtotime('-360 minutes'));
$employee->bo_theme = 'default';
$employee->default_tab = 1;
$employee->active = true;
$employee->id_profile = 1;
$employee->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
$employee->bo_menu = true;
if (!$employee->add()) {
	$this->setError($this->translator->trans('Cannot create admin account', [], 'Install'));

	return false;
}

 

Edited by joseantgv (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...