How can I programmatically flag a user?
Have you checked that $account-&gt;uid exists? I'm not sure that a new user would have a UID inside of hook_user_presave(). You may want try setting the flag in hook_user_insert() instead. Also worth making sure that users are allowed to be flagged by your flag type.