drupal ajax登录返回用户ID
我正在为 drupal 6 制作一个关于用户登录的 ajax 模块。
我需要
- 在用户登录表单上禁用重定向(我知道我需要在此表单上进行表单更改: http://api.drupal.org/api/drupal/modules--user--user.module/function/user_login/6 但是什么以及如何?)
- 返回包含成功/失败和用户 UID 的 json 响应。
知道我该怎么做吗?
谢谢。
I'm making an ajax module for drupal 6 in regards to user login.
I need to
- disable redirect on the user login form (I know I need to do a form alter on this form: http://api.drupal.org/api/drupal/modules--user--user.module/function/user_login/6 but what and how?)
- get back a json response containing the success/fail and the user's UID.
Any idea how I do this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从 ajax_register 模块 或 ajax 模块 并自定义它。
或者您为此目的创建自己的模块。您必须实施 hook_form_user_login_form_alter,根据需要更改表单,添加一些 Javascript 并编写一个回调函数来调用
user_login_submit()
并发送 JSON 响应。我强烈建议使用现有的模块。可能不止上面提到的两个。尝试搜索“drupal login ajax”。
You could start with ajax_register module or ajax module and customize it.
Or you create your own module for that purpose. You'd have to implement hook_form_user_login_form_alter, alter the form as needed, add some Javascript and write a callback function that calls
user_login_submit()
and sends a JSON response.I strongly recommend to use an existing module. There might be more than the two mentioned above. Try searching for "drupal login ajax".