Updates generated user.

@since 1.0.0

@access protected
@param mixed $user_id The user id to update.
@param array $fields The array of fields to update.
@return mixed Updated user ID on success, otherwise a WP_Error object.
437798
protected function _updateObject( $user_id, $fields ) {
		$fields['ID'] = $user_id;
		$updated = wp_update_user( $fields );
		if ( $updated && ! is_wp_error( $updated ) ) {
			$this->_debug( 'Updated user ' . $user_id );
		} elseif ( is_wp_error( $updated ) ) {
			$this->_debug(
				'Update failed for user %d with message [%s] %s',
				$user_id,
				$updated->get_error_code(),
				$updated->get_error_message()
			);
		} else {
			$this->_debug( 'Update failed for user ' . $user_id );
		}

		return $updated;
	}
648521
public function update(UpdateUserRequest $request, $id)
    {
        $user = User::find($id);
        $user->update($request->intersect(['email','name','password']));
        return Response::json(['updated' => true ]);
    }
382956
public function updateUserAsync($user_id, $payload_account)
    {
        return $this->updateUserAsyncWithHttpInfo($user_id, $payload_account)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }
183808
public function update(UpdateUserRequest $request, $id)
    {
        $user = $this->user->findOrFail($id);
        $user->update($request->except('password'));

        if($request->filled('password')) $user->password = bcrypt($request->password);
        if(! $request->filled('is_admin')) $user->is_admin = 0;

        $user->save();

        return redirect('admin/users');
    }
1058046
public function profile(string $userId, array $fields = []): UserResponse
    {
        $allowedFields = $this->getAllowedFields();
        $fields = empty($fields) ? $allowedFields : $fields;

        if ($fields !== $allowedFields) {
            foreach ($fields as $field) {
                if (!\in_array($field, $allowedFields, true)) {
                    throw new InvalidKeyException(sprintf(
                        '%s is not a valid value. fields must only contain "%s".',
                        $field,
                        implode(', ', $allowedFields)
                    ));
                }
            }
        }

        $request = new UserRequest($this->pageToken, $fields);
        $response = $this->client->get($userId, $request->build());

        return new UserResponse($response);
    }
1272120
public function update(array $data): User
    {
        $user = wp_update_user(array_merge($data, [
            'ID' => $this->ID
        ]));

        if (is_a($user, 'WP_Error')) {
            throw new UserException($user->get_error_message());
        }

        return $this;
    }
46631
public function editUser($user_id = null)
    {
        $this->setUser($user_id);
        $this->setTitleEditUser();
        $this->setBreadcrumbEditUser();
        $this->controlAccessEditUser($user_id);

        $this->setData('user', $this->data_user);
        $this->setData('roles', $this->role->getList());
        $this->setData('can_delete', $this->canDeleteUser());
        $this->setData('is_superadmin', $this->isSuperadminUser());
        $this->setData('password_limit', $this->user->getPasswordLength());

        $this->submitEditUser();
        $this->outputEditUser();
    }
1046809
public function patchUser($id, array $fields)
    {
        $request = $this->client->patch($this->customer['url'].'/api/users/'.$id);

        $request->setAuth($this->customer['username'], $this->customer['password']);
        $request->setBody(json_encode($fields));

        $response = $request->send();

        return json_decode($response->getBody(true));
    }
1135462
public function update(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-update');
    }
639101
public function bindUserID($user_id, $binding)
    {
        if (!$binding || !$user_id) {
            return null;
        }
        $qb = $this->app->make(Connection::class)->createQueryBuilder();

        $or = $qb->expr()->orX();
        $or->add($qb->expr()->eq('user_id', intval($user_id, 10)));
        $or->add($qb->expr()->eq('binding', ':binding'));

        $and = $qb->expr()->andX();
        $and->add($qb->expr()->comparison('namespace', '=', ':namespace'));
        $and->add($or);

        $qb->delete('OauthUserMap')->where($and)
           ->setParameter(':namespace', $this->getHandle())
           ->setParameter(':binding', $binding)
           ->execute();

        return $this->app->make(Connection::class)->insert(
            'OauthUserMap',
            [
                'user_id' => $user_id,
                'binding' => $binding,
                'namespace' => $this->getHandle(),
            ]);
    }
1324381
public function update($id, array $fields)
    {
        $xml = "<employee>";

        foreach ($fields as $field => $value) {
            $xml .= "<field id=\"{$field}\">{$value}</field>";
        }

        $xml .= "</employee>";

        return $this->post("employees/{$id}", $xml);
    }
718100
public function set( $key, $value, $user_id = null ) {
		if ( ! isset( $user_id ) ) {
			$user_id = $this->user_id;
		}
		if ( $user_id <= 0 ) {
			return false;
		}

		return update_user_meta( $user_id, $this->get_meta_key( $key ), $value );
	}
758752
public function addBlogUser( $user_id ) {
		$user = get_userdata( $user_id );
		if ( $user && user_can( $user, 'edit_posts' ) ) {
			$slug = $user->user_nicename;
			$name = trim( "{$user->first_name} {$user->last_name}" );
			if ( empty( $name ) ) {
				$name = $user->display_name;
				if ( empty( $name ) ) {
					$name = $slug;
				}
			}
			$results = wp_insert_term(
				$name, self::TAXONOMY, [
					'slug' => $slug,
				]
			);
			if ( is_array( $results ) ) {
				add_term_meta( $results['term_id'], 'contributor_first_name', $user->first_name, true );
				add_term_meta( $results['term_id'], 'contributor_last_name', $user->last_name, true );
				return $results;
			}
		}
		return false;
	}
967588
public function set($product_id, $user_id)
    {
        $list = (array) $this->getList(array('user_id' => $user_id));

        foreach ($list as $item) {
            if ($item['product_id'] == $product_id) {
                return $list;
            }
        }

        $limit = $this->getLimit();

        if (!empty($limit)) {
            $exceeding = array_slice($list, $limit - 1, null, true);
        }

        if (!empty($exceeding)) {
            foreach (array_keys($exceeding) as $product_view_id) {
                $this->delete($product_view_id);
            }
        }

        $data = array(
            'user_id' => $user_id,
            'product_id' => $product_id
        );

        $this->add($data);
        return $list;
    }
649559
static function _get_user_by_id( $user_id ) {
            self::$_static_logger->entrance( "user_id = {$user_id}" );

            $users = self::get_all_users();

            if ( is_array( $users ) ) {
                if ( isset( $users[ $user_id ] ) &&
                     $users[ $user_id ] instanceof FS_User &&
                     $user_id == $users[ $user_id ]->id
                ) {
                    return $users[ $user_id ];
                }

                // If user wasn't found by the key, iterate over all the users collection.
                foreach ( $users as $user ) {
                    /**
                     * @var FS_User $user
                     */
                    if ( $user_id == $user->id ) {
                        return $user;
                    }
                }
            }

            return null;
        }
1219355
public static function set_user_id($user_id) {
	if (self::is_active() == false) {
		$exception = bootstrap::get_library('exception');
		throw new $exception('inactive session');
	}
	
	$_SESSION['_session_user_id'] = $user_id;
}
1236930
public function update($id, UserUpdateRequest $request)
	{
		$level = "danger";
		$message = " You are not permitted to update users.";

		if ( Shinobi::can ( config('watchtower.acl.user.edit', false) ) ) {
			$user = $this->model::findOrFail($id);
			if ($request->get('password') == '') {
        		$user->update( $request->except('password') );
    		} else {
        		$user->update( $request->all() );
    		}
			$level = "success";
			$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! User edited.";
		}
		
		return redirect()->route( config('watchtower.route.as') . 'user.index')
				->with( ['flash' => ['message' => $message, 'level' =>  $level] ] );
	}