问题
Can anybody tell me, what the "user state" in the ZfcUser is doing exactly and why we may need it? What does this user state mean (I assume it's not the role meant by it)?
回答1:
Basically it's a flag to indicate the state of a user. Sometimes you need to be able to disable users, or otherwise affect their 'state' without actually deleting them from the table. That's what the state column is intended for if you use such a system.
As a simple example, think of a temporarily banned user on a forum, you don't want to delete them, so you set their state to banned, and only allow users who aren't banned to log in.
Of course there could be more states to indicate other things, such as an account that hasn't yet been validated by way of confirmation email, or requires administrator approval, whatever makes sense in your user ecosystem really. It could be you don't need any at all, in which case you can safely ignore it.
回答2:
User state can be used by adding two values to your config array in zfcuser.global.php
In order to use state as active/inactive for example you can add this:
'enable_user_state' => true, 'allowed_login_states' => array(1),
Now the user state has to be set to 1 from an admin, otherwise login will fail for that specific user.
来源:https://stackoverflow.com/questions/15272279/what-exactly-is-the-user-state-in-zfcuser