How to change status and update account? How can i change status to 0 and update an existing user account?

Here is the code i tried:

$account = \Drupal::currentUser();
$account-&gt;status = 0;
$account-&gt;save();


It gives me error :  Call to undefined method Drupal\Core\Session\AccountProxy::save().
The account proxy class doesn't have a method called save. Refer to the API docs. 

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Session%21AccountProxy.php/class/AccountProxy/8.2.x

What you want is the block() method:

$account-&gt;block();


As $account should be an instance of UserInterface, returned front getAccount of AccountProxy. But without seeing the rest of the code its hard to see if this is the right approach for what you are trying to do.

If you could get the user account another way, then you could do:

$account = \Drupal\user\Entity\User::load('uid arg');
$account-&gt;block();
$account-&gt;save();