简体   繁体   English

Drupal:将模块的功能集成到另一个模块(电子邮件验证和留言簿)

[英]Drupal: Integration of a module's functionality to another (Email Verify and Guestbook)

Apologies if this question seems to elementary. 抱歉,如果这个问题似乎很简单。 I'm a Drupal newbie with some knowledge of PHP and MySQL, and am wondering if it is possible to integrate the functionality of the Email Verify module to the Drupal Guestbook module. 我是一位具有PHP和MySQL知识的Drupal新手,想知道是否可以将Email Verify模块的功能集成到Drupal Guestbook模块中。 The latter comprises of a form with email field which I want to be validated using the Email Verify module, whose configuration options only allow checking on the User Registration Form and the User Profile Form. 后者包括一个带有电子邮件字段的表单,我想使用“电子邮件验证”模块来对其进行验证,该表单的配置选项仅允许检查“用户注册表单”和“用户配置文件表单”。 I'd like to expand the functionalities to include the Guestbook, and possibly other forms on the site in the future. 我想扩展功能,以包括留言簿以及将来站点上的其他表格。 Any suggestions on how I can get started would be appreciated. 关于如何上手的任何建议将不胜感激。

PS - I'm using Drupal v7.39 PS-我正在使用Drupal v7.39

The function that validated the emails in the email verify module is this: 在电子邮件验证模块中验证电子邮件的功能是:

function email_verify_edit_validate($form, &$form_state) {
  if (!user_access('bypass email verification') && $form_state['values']['op'] != t('Cancel account')) {
    // Validate the e-mail address.
    if ($error = email_verify_check($form_state['input']['mail'])) {
      form_set_error('mail', $error);
    }
  }
}

So you could do a form_alter or a form_FORMID_alter on your form and add this: $form['#validate'][] = 'email_verify_edit_validate'; 因此,您可以在表单上执行form_alterform_FORMID_alter并添加以下内容: $form['#validate'][] = 'email_verify_edit_validate'; But only if the input field on your form has the element named mail. 但是,仅当表单上的输入字段具有名为mail的元素时。

Alternatively, you could create your own validation function that implements part of the email verify function, specifically the email_verify_check($form_state['input']['mail']) function part, replacing the ['mail'] with the appropriate id of your form element. 另外,您可以创建自己的验证功能,该功能实现电子邮件验证功能的一部分,特别是email_verify_check($form_state['input']['mail'])功能部分,用适当的ID替换['mail']您的表单元素。

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

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