繁体   English   中英

如何将html表单的输入转发到Drupal 7登录表单?

[英]How do I forward inputs of a html form to Drupal 7 login form?

我已经在html中创建了一个表单,如下所示:

<form class="login active">
    <h3>Login</h3>
    <div>
        <label>Username:</label>
        <input type="text" name="username"/>
    </div>
    <div>
        <label>Password: </label>
        <input type="password" name="password"/>
        <label><a href="forgot_password.html" rel="forgot_password" class="forgot linkform">Forgot your password?</a></label>
    </div>
    <div class="bottom">
        <div class="remember"><!--<input type="checkbox" />--><span><!--Keep me logged in--></span></div>
        <input type="submit" value="Login"></input>
        <a href="register.html" rel="register" class="linkform">You don't have an account yet? Register here</a>
        <div class="clear"></div>
    </div>
</form>

我需要做的是使用户使用我的HTML表单登录Drupal。 提前致谢

在template.php中编写:

<?php
function mytheme_theme(&$existing, $type, $theme, $path) {
      $hooks['user_login'] = array(
      'template' => 'templates/user_login',
      'render element' => 'form',
      // other theme registration code...
    );

    return $hooks;
}

function mytheme_preprocess_user_login(&$variables) {
    $variables['intro_text'] = t('This is my awesome login form');
    $variables['rendered'] = drupal_render_children($variables['form']);
}
?>

然后,您可以在目录templates创建user_login.tpl.php

更多信息: 定制登录表单函数hook_theme

使用hook_menu为将处理您的发布请求的自定义模块注册自定义路径可以解决您的问题: https : //api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/ 7

之后,只需使用类似user_authenticate的功能来对用户进行身份验证: https : user_authenticate

这两个链接都为您提供了示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM