Airship\Cabin\Bridge\Blueprint\UserAccounts::editUserCustomFields PHP Method

editUserCustomFields() public method

Only change the custom fields.
public editUserCustomFields ( integer $userId, string $customFields = '[]' ) : boolean
$userId integer
$customFields string
return boolean
    public function editUserCustomFields(int $userId, string $customFields = '[]') : bool
    {
        $this->db->beginTransaction();
        $this->db->update('airship_users', ['custom_fields' => \json_encode(\json_decode($customFields, true))], ['userid' => $userId]);
        return $this->db->commit();
    }

Usage Example

Esempio n. 1
0
 /**
  * Create a new user
  *
  * @route crew/users/new
  * @param string $userId
  */
 public function createUser(string $userId = '')
 {
     $userId = (int) $userId;
     $user = $this->account->getUserAccount($userId, true);
     $post = $this->post(new NewUserFilter());
     if ($post) {
         if (!empty($post['preferences'])) {
             if (\is_string($post['preferences'])) {
                 $post['preferences'] = \json_decode($post['preferences'], true);
             }
         } else {
             $post['preferences'] = [];
         }
         $userId = $this->account->createUser($post);
         if ($userId) {
             $this->account->editUserCustomFields($userId, $post['custom_fields'] ?? '[]');
             \Airship\redirect($this->airship_cabin_prefix . '/crew/users');
         }
     }
     $this->lens('crew/user_new', ['active_link' => 'bridge-link-admin-crew-users', 'user' => $user, 'groups' => $this->account->getGroupTree()]);
 }