ayush
ayush

Reputation: 14568

Anonymous user form submission drupal 7

I have a situation where after doing the basic registration the user is redirected to a page where he needs to fill a small form.

i aim at implementing the hook_user_insert and hook_menu to do something like this

function registration_user_insert(&$edit, $account, $category){
drupal_goto('splan/'.$edit['uid']);
}

function registration_menu() {
$items['splan/%'] = array(
'title' => 'Select a Plan',
'page callback' => 'drupal_get_form',
'page arguments' => array('selectplan_form'),
'access callback' => TRUE,
'type' => MENU_CALLBACK
);
return $items;
}

In selectplan_form i will define my new form and then using the uid i would save data into user table.

Now what is happening is after the basic user registration form is being submitted the redirection to splan/uid is happening but i also get the following error.

You are not authorized to access this page.

Now i have changed permissions to allow anony. users to create and edit webform but still the problem exists.

Please help!!!!!!!!

Upvotes: 0

Views: 1100

Answers (2)

mattacular
mattacular

Reputation: 1889

Is it imperative that the form you refer to be filled out AFTER a user registers? If so, its a somewhat tricky situation. Either way, putting a drupal_goto in the user_insert hook will interrupt the registration process. If your form doesn't require the user to be registered first, you should simply alter the registration form to include whatever extra fields you have on your form. To do this, you need to implement a hook_from_alter():

http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_form_alter/7

Upvotes: 1

Bart
Bart

Reputation: 433

Try removing 'access callback' => TRUE, and add 'access arguments' => array('access content'), instead.

Perhaps you forgot to clear the cache?

Upvotes: 1

Related Questions