method edit documentation in bbn\User\Manager
Creates a new user and returns its configuration (with the new ID)
function(array $cfg, string $id_user = NULL)
{
$u =& $this->class_cfg['arch']['users'];
$fields = array_unique(array_values($this->class_cfg['arch']['users']));
$cfg[$u['active']] = 1;
if (!empty($this->class_cfg['arch']['users']['cfg'])) {
if (empty($cfg[$this->class_cfg['arch']['users']['cfg']])) {
$cfg[$this->class_cfg['arch']['users']['cfg']] = [];
}
elseif (is_string($cfg[$this->class_cfg['arch']['users']['cfg']])) {
$cfg[$this->class_cfg['arch']['users']['cfg']] = json_decode($cfg[$this->class_cfg['arch']['users']['cfg']], true);
}
foreach ($cfg as $k => $v){
if (!\in_array($k, $fields)) {
$cfg[$this->class_cfg['arch']['users']['cfg']][$k] = $v;
unset($cfg[$k]);
}
}
$cfg[$this->class_cfg['arch']['users']['cfg']] = json_encode($cfg[$this->class_cfg['arch']['users']['cfg']]);
}
else {
foreach ($cfg as $k => $v){
if (!\in_array($k, $fields)) {
unset($cfg[$k]);
}
}
}
if (!$id_user && isset($cfg[$u['id']])) {
$id_user = $cfg[$u['id']];
}
if ($id_user && ( !isset($cfg[$this->class_cfg['arch']['users']['email']])
|| bbn\Str::isEmail($cfg[$this->class_cfg['arch']['users']['email']]) )
) {
if ($this->db->update(
$this->class_cfg['tables']['users'], $cfg, [
$u['id'] => $id_user
]
)
) {
$cfg['id'] = $id_user;
return $cfg;
}
}
return null;
}
Creates a new user and returns its configuration (with the new ID) BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions