匿名用户表单提交 drupal 7
我遇到的情况是,在完成基本注册后,用户被重定向到一个需要填写小表格的页面。
我的目标是实现 hook_user_insert 和 hook_menu 来执行类似的操作
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;
}
在 selectplan_form 中,我将定义新表单,然后使用 uid 将数据保存到用户表中。
现在发生的情况是在提交基本用户注册表单后,发生了到 splan/uid 的重定向,但我也收到以下错误。
You are not authorized to access this page.
现在我已更改权限以允许匿名。用户创建和编辑网络表单,但问题仍然存在。
请帮忙!!!!!!!
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!!!!!!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试删除
'access callback' => TRUE,
并添加'access argument' => array('访问内容'),
代替。也许您忘记清除缓存?
Try removing
'access callback' => TRUE,
and add'access arguments' => array('access content'),
instead.Perhaps you forgot to clear the cache?
您提到的表格是否必须在用户注册后填写?如果是这样,情况就有点棘手了。无论哪种方式,将 drupal_goto 放入 user_insert 挂钩中都会中断注册过程。如果您的表单不要求用户首先注册,您只需更改注册表以包含表单上的任何额外字段即可。为此,您需要实现一个 hook_from_alter():
http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_form_alter/7
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