[development] user.module/user_register_submit and $merge_data['status']

Rob Koberg rob at koberg.com
Fri Aug 20 16:17:35 UTC 2010


Hi,

I finally got around to do this. Works great. Thanks!

best,
-Rob

On Mon, Aug 16, 2010 at 4:39 AM, Steven Jones
<steven.jones at computerminds.co.uk> wrote:
> Hi Rob,
>
> If you follow the code in user_register_submit() you'll see that
> user_save() calls hook_user, with the $op of insert when creating a
> new user. If you implement that hook, and make changes to the user in
> the database, then they will be picked up because the last thing that
> user_save does is a user_load().
>
> We exploited this in the following workflow:
> 1. Drupal set to require admin approval for accounts.
> 2. When user registers, we hook into hook_user (insert) to check to
> see if they entered a valid 'registration code' and if they did, we
> update the DB to set the status to 1.
> 3. Otherwise the users status will be what Drupal set it as, and it
> will email accordingly.
>
> Regards
> Steven Jones
> ComputerMinds ltd - Perfect Drupal Websites
>
> Phone : 024 7666 7277
> Mobile : 07702 131 576
> Twitter : darthsteven
> http://www.computerminds.co.uk
>
>
>
> On 16 August 2010 12:32, Rob Koberg <rob at koberg.com> wrote:
>> On Sun, Aug 15, 2010 at 6:50 PM, Lee Rowlands <contact at rowlandsgroup.com> wrote:
>>> Hi Rob
>>> I seem to remember tackling this before by adding a new submit handler to
>>> the user register form for a particular path which reflected the role.
>>> and making sure the submit handler ran after user_register_submit. In the
>>> submit handler I then ran db_query to update the user status in the db.
>>
>> Yes, but the emails go out in the user_register_submit.
>>
>> -Rob
>>
>>>
>>> Lee
>>>
>>>
>>> On Sun, 2010-08-15 at 18:36 -0700, Rob Koberg wrote:
>>>
>>> Bueller?
>>>
>>> Based on how a user registers, how can I set one group of users to be
>>> blocked after registration and another group that is not blocked?
>>>
>>> The current code is:
>>>
>>> $merge_data['status'] = variable_get('user_register', 1) == 1;
>>>
>>> so there is no way to allow for more than one 'Public registrations'.
>>> I have seen loggintobaggan. Perhaps there could be a setting to allow
>>> a filter to provide access.
>>>
>>> $merge_data['status'] = $form_state['status'] ? $form_state['status']
>>> : variable_get('user_register', 1) == 1;
>>>
>>> Or is there some other way than modifying the core to prevent
>>> $merge_data['status'] = variable_get('user_register', 1) == 1; ? Is it
>>> possible to completely override the user_register_submit() somehow?
>>>
>>> -Rob
>>>
>>> On Sat, Aug 14, 2010 at 4:29 PM, Rob Koberg <rob at koberg.com> wrote:
>>>> Hi,
>>>>
>>>> New to Drupal and relatively new to PHP.
>>>>
>>>> I have been working on a COPPA module to constrain the registration
>>>> process on a non-profit site for young girls. COPPA is important
>>>> because it is a legal requirement to slightly filter the usage of a
>>>> web site by a person under 13 in the U.S (for any site that registers
>>>> users). I have looked at and tried:
>>>>
>>>> http://drupal.org/project/coppa
>>>>
>>>> I don't see it doing much, or perhaps it is under documented? Anyway,
>>>> I have two sets of users:
>>>>
>>>> * over 13: These users can register, get an email, and access the site
>>>> right away
>>>>
>>>> * under 13: These users are initially blocked. At registration time,
>>>> when it is determined they are under 13, a  lightbox comes up with
>>>> fields for the parent/guardian name, email and email confirm.
>>>>
>>>> So I want two different settings for their /admin/user/settings/Public
>>>> registrations, blocked and not blocked. The code in user.module has:
>>>>
>>>> if (!$admin) {
>>>>    // Set the user's status because it was not displayed in the form.
>>>>    $merge_data['status'] = variable_get('user_register', 1) == 1;
>>>>  }
>>>>
>>>> I would like to have a way to block('administrator approval is
>>>> required')/unblock('no administrator approval is required') the user
>>>> based on age. I just use the "block('administrator approval is
>>>> required')" as a way to reuse the admin user settings emails. Actually
>>>> what happens is the parent is emailed an URL, and when they click it
>>>> the user's status is set to 1.
>>>>
>>>> The only way I could see to do this (remember, newbie) was to change
>>>> the above user.module code to:
>>>>
>>>> if (!$admin) {
>>>>    // Set the user's status because it was not displayed in the form.
>>>>    $merge_data['status'] = $form_state['status'] ?
>>>> $form_state['status'] : variable_get('user_register', 1) == 1;
>>>>  }
>>>>
>>>> I realize this should not be in a site that does not control the
>>>> $form_state['status'], but is there some cleaner way to do this
>>>> without changing a base module?
>>>>
>>>> thanks,
>>>> -Rob
>>>>
>>>
>>>
>>
>


More information about the development mailing list