[development] Creating multiple login blocks with, different validation rules.

Anth malkouna at yahoo.com.au
Fri May 14 00:51:23 UTC 2010

Hi Earnie,

Thanks for the answer and that's one of the things to do, but my problem 
at the moment with that path is that in hook_form_alter there doesn't 
seem to be anything that I can use to identify which block it is.  Am I 
missing something obvious?

If there is nothing in the $form then what I think I actually want to do 
is use some code to generate the form and as I have access to the $form 
array to put in my own validation rule or hidden $form element or 
whatever to distinguish between the different blocks.  So I'm trying to 
generate the user_login_block myself so I can alter the $form array but 
can't get it to work.  In my block code if I call 
drupal_get_form('user_login_block') for the block content everything is 
fine but I can't alter the form object.  So I'm trying to do the same 
steps as drupal_get_form, i.e. the code below and the user login block 
displays but there is a bunch of stuff missing from it so it doesn't 
actually submit.

Am I making this harder than I need to for what I'm trying to achieve?


   $form_state = array();
   $form = drupal_retrieve_form('user_login_block', $form_state);
   drupal_prepare_form('user_login_block', $form, $form_state);
   $block['content'] = drupal_render_form('user_login_block', $form);

On 14/05/2010 3:44 AM, development-request at drupal.org wrote:
> Message: 1
> Date: Thu, 13 May 2010 08:26:46 -0400
> From: Earnie Boyd<earnie at users.sourceforge.net>
> Subject: Re: [development] Creating multiple login blocks with
> 	different	validation rules.
> To:development at drupal.org
> Message-ID:<4BEBF006.9010907 at users.sourceforge.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> Anth wrote:
>> >  Hi,
>> >  Does anyone have ideas on how to implement the function in the subject?
>> >  Basically I want a page with two login blocks, one for general users and
>> >  one for premium users. I've used multiblock to get the two blocks up
>> >  there but I need the two different blocks to work different for the
>> >  different user types. That is if a general user tries to login on the
>> >  premium login it fails and vice versa. Is there any easy way to do this
>> >  or do I have to recreate my forms manually?
> You don't need to start from scratch but you do need to code using
> hook_form_alter to add the appropriate form elements and also a
> hook_user to capture the user operations and operate on the appropriately.
> -- Earnie -- http://progw.com -- http://www.for-my-kids.com

More information about the development mailing list