How will a predefined form behave if we have two different forms that implement hook_form_alter?
I would explain my question by an example, because currently I got a crash on it:
I have a predefined user_login form in user.module
I created two new blocks called author_login and creator_login. Each of these module using the form user_login and adding new validating properties for each form by using function hook_form_alter().
The new validating properties are:
For author_login block: if user doesn't have author role, user will not be logged into system, error: "you don't have author role"
For creator_login block: if user doesn't have creator role, user will not be logged into system, error: "you don't have creator role"
But the problem is: the new login block I created works fine if only one of two modules is enable. If I enable both modules, no user cannot log in to the system through these module.
For example, I have both modules enabled, I go to author_login block and log an user named Mark, who has role Author, to the system, an error message displayed: "the user Mark doesn't have creator role". And similar to creator_login block.
Why does this happen? I thought that the hook_form_alter will alter different properties to each new module we created, make each new form works separately. But from this case I encountered, it seem like the user_login form validate all new properties that I added by using hook_form_alter. And how can I avoid this as I want these two form to work separately?
Notes: I am really sorry to post this question here because I posted the question on drupal.stackexchange but there was only one answer that couldn't help me much in finding the solution. I really need help on this question. Many thanks!