Exemple #1
0
        redirect(REF);
    }
}
//check if email is valid email
if (!$OssnUser->isEmail()) {
    ossn_trigger_message(ossn_print('email:invalid'), 'error');
    redirect(REF);
}
//check if password then change password
if (!empty($password)) {
    if (!$OssnUser->isPassword()) {
        ossn_trigger_message(ossn_print('password:error'), 'error');
        redirect(REF);
    }
    $salt = $OssnUser->generateSalt();
    $password = $OssnUser->generate_password($password, $salt);
    $params['names'] = array('first_name', 'last_name', 'email', 'type', 'password', 'salt');
    $params['values'] = array($user['firstname'], $user['lastname'], $user['email'], $user['type'], $password, $salt);
}
//save
if ($OssnDatabase->update($params)) {
    //update entities
    $guid = $entity->guid;
    if (!empty($guid)) {
        $entity->owner_guid = $guid;
        $entity->type = 'user';
        $entity->data->gender = $user['gender'];
        $entity->data->birthdate = $user['birthdate'];
        $entity->save();
    }
    ossn_trigger_message(ossn_print('user:updated'), 'success');