手动登录用户
我正在开发一个 drupal 网站,允许用户在登录的同时发布内容。我已成功添加电子邮件和密码字段更改为原始表单,但我不知道应该如何实际登录用户。 (我的计划是在创建内容之前的验证步骤中执行此操作,以使登录用户成为该内容的所有者)。
我可以在 user.module API 中找到三个看起来正确的函数:
- http://api .drupal.org/api/function/user_login_authenticate_validate/6
- http:// api.drupal.org/api/function/user_authenticate/6
- http:// /api.drupal.org/api/function/user_authenticate_finalize/6
现在,我的问题是它是哪一个?我是否走在正确的轨道上?
I'm working on a drupal site where I allow users to login while at the same time posting a content. I've successfully added email & password fields to the original form, but I'm stuck as to how I should actually log in the user. (My plan is to do it in the validation step, before the content is created, to make the logged in user owner to the content).
I can find three functions in user.module API that somehow looks right:
- http://api.drupal.org/api/function/user_login_authenticate_validate/6
- http://api.drupal.org/api/function/user_authenticate/6
- http://api.drupal.org/api/function/user_authenticate_finalize/6
Now, my question is which one is it? Am I even on the right track?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦您检查了用户名/密码并发现它们验证并获得了用户的
$uid
,您将执行如下操作:因此您覆盖全局
$user
code> 对象并调用 user_authenticate_finalize。更新:
一步完成验证和登录将如下所示:
Once you've checked the username/password and have found that they validate and got the
$uid
of the user, you would do something like this:So you overwrite the global
$user
object and call user_authenticate_finalize.Update:
Doing the validation and login with one step would look like this: