Posted by pyone on October 26, 2012 at 8:10am
I have all together 4 user roles.
Users of role 1 & 2 will be activated only when administrator approved them after registration.
But users of role 3 & 4 can immediately access the site after registration.
Is there any way to achieve it by existing module ?
I got different user profiles using profile2 module and I'm using drupal 7.15.
Comments
I've achieved this using this
I've achieved this using this hook:
function mymodule_form_profile2_edit_PROFILETYPE_form_alter(&$form, &$form_state){$form["account"]["status"]["#default_value"] = FALSE;
}
I've configured the site to simple registration (with email confirmation), but if the profile type is PROFILETYPE then the account is disabled by default.
I've to use the profile registration path module to hook this form alter.
Hope to be usefull
Yes, it does. Thanks you so
Yes, it does.
Thanks you so much for your help.
I know it's an old thread but...
I'm trying to do the same thing on my website; however I'm not using the profile2 module as I don't need it.
Do you have any idea ?
Thanks for your help.
Can be done using rules
Hi Naroj,
Create rule react on event "After saving a new user account" and then call action "Block a user". Make sure check your role in conditions which you want to block all users with same role.
Hi Virang, True that rule
Hi Virang,
True that rule working perfectly fine if we have 2 role like role1 and role2 and we want admin approval only for role1 then create rule.
thanks
mayuri
Hi, the method is the same
Hi,
the method is the same but you must hook the registration form submit and check if a role is selected and then modify the "status" value.
Thank you very much!
I will follow your advice, thank you for helping me so fast ! :)
You're welcome ;)
You're welcome ;)
Hi ! Just tried your
Hi !
Just tried your solution. My code is the following one:
<?phpfunction mymodule_user_register_submit_alter($form, &$form_state) {
//Testing the role selected
if($form_state['autoassignrole_user']['user_roles'] == $roles[7])
{
//Activation of the new account
$form["account"]["status"]["#default_value"] = TRUE;
}
else
{
//The account is disabled
$form["account"]["status"]["#default_value"] = FALSE;
}
}
?>
However, it doesn't work... I think I'm doing something wrong, but I don't know why (I'm quite new to Drupal and php ^^").
Hi there is not an alter for
Hi there is not an alter for submits...you have to alter the register form and add a custom submit (or validate) function where you check the value submitted and change the status.
I think you should read some documentation about forms api and flow.
Try here http://drupal.org/node/1043838 :)
Not working the solution of reysharks for me
hi, i just did what reysharks said but it does not work for me....
i have installed the profile2 and profile2 rgpath modules
this is my mymodule.module file
function mymodule_form_profile2_edit_empresa_form_alter(&$form, &$form_state){$form["account"]["status"]["#default_value"] = FALSE;
}
i use this path to register the profile type "empresa": www.mysite.com/empresa/register
but when i register an user with this path the user is active by default, and i need them disable or blocked by default
any idea?
i could make it work
Hi i could solve this problem...
my problem was that i use the loginTobbogan module and thats why my hook didnt work...
but now my question is, how to make it work with loginTobogan?
How to apply hook
Hi,
I have the same problem but I don't know how to use the hook mentioned before, I hope someone can explain me how to use this hook, I'd be so grateful.
Hi ,in admin under account
Hi ,
in admin under account settings select Visitors option.
just create rule that will Block user once they register .