如何将html表单的输入转发到Drupal7登录表单


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://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_authenticate/7

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