Title: OTP by Email for Contact Form 7
Author: Aurovrata Venet
Published: <strong>2020 年 12 月 1 日</strong>
Last modified: 2023 年 5 月 2 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/otp-by-email.svg)

# OTP by Email for Contact Form 7

 作者：[Aurovrata Venet](https://profiles.wordpress.org/aurovrata/)

[下载](https://downloads.wordpress.org/plugin/otp-by-email.1.2.0.zip)

 * [详情](https://cn.wordpress.org/plugins/otp-by-email/#description)
 * [评价](https://cn.wordpress.org/plugins/otp-by-email/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/otp-by-email/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/otp-by-email/#developers)

 [支持](https://wordpress.org/support/plugin/otp-by-email/)

## 描述

Use this CF7 extension to enable OTP links to be inserted into confirmation/notification
emails sent to email addresses submitted through your CF7 forms. The OTP is a unique
link the email inbox user needs to click to confirm their address. The link is valid
by default for 72 hours and can be customised.

## 安装

 1. Install Contact Form 7 plugin
 2. Install OTP by Email plugin extension
 3. OTP tag requires an email field in your CF7 forms.
 4. In CF7 forms with email fields, a mail tag `[otp-<field-name>]` will be available
    to insert into your notification/confirmation email which will all a unique time-
    limited URL for users to confirm their email.
 5. In the form editor page, the OTP tab allows you to set the pages to redirect to
    when an email is validated or fails due to an outdated link.

## 常见问题

### 0. What does this plugin do ?

If you are collecting an email address in your CF7 form from a visitor, you can 
use this plugin to validate that email.

The email field name will be used to create a unique OTP mail tag shortcode to insert
into your notification mail (sent to that email). The shortcode will be replaced
by a unique URL which the recipient can click on to validate their email. This unique
link is created using WordPress nonce API, and it stored in the DB as a transient
with a default validity of 72 hours (3 days). You can customise this validity period,
please refer to the FAQ below for more details. When a recipient clicks on a valid
link, they are redirected to the _On Success_ page you configured in the OTP tab.
If the link is no longer valid, they are taken to the _On failure_ page instead,
where you may give them the option to send them a new OTP link.

You can use this plugin to go beyond simple email validation, as each valid user
now has a unique way to identify themselves on your server. I have used this plugin
to create a conference registration and submission form for speakers without having
them to actually create a user account on the server. A visitor registers as a speaker,
and once their email is validated, they use their OTP link (which expires a week
prior to the conference start date) in order to submit talks for the conference 
without having to have an account.

If you need to explore such functionality, you can contact me on “vrata at syllogic
dot in”.

### 1. Is it possible to change the time-limit for the link validity ?

The unique confirmation link has a 3-day (72 hours) validity by default, you can
change it with the following filter,

    ```
    add_filter('otp_by_email_lifetime', 'otp_by_email_validity',10,3);
    function otp_by_email_validity($limit, $email, $form_id){
      //you can set different time limits for different email domains or form ID.
      $limit = 24 * HOUR_IN_SECONDS;  //limit is in seconds.
      return $limit;
    }
    ```

### 2. How to retrieve an email that has been validated ?

Use the following filter,

    ```
    add_filter('otp_by_email_validated', 'otp_validated',10,3);
    function otp_validated($url, $email, $form_id){
      //you can identify a validated email and the form ID from which it was submitted.
      //you can also change the URL to which you want to redirect.
      return $url;
    }
    ```

### 3. How to retrieve an email that failed due to an outdated link ?

Use the following filter,

    ```
    add_filter('otp_by_email_failed', 'otp_failed',10,3);
    function otp_failed($url, $email, $form_id){
      //you can identify a failed email and the form ID from which it was submitted.
      //you can also change the URL to which you want to redirect.
      return $url;
    }
    ```

### 4. Is it possible to get an OTP link for an email programmatically ?

Yes, you can use the following function to retrieve a unique link,

    ```
    /**
    * Funiton to get a link for email validation.
    * @param String $email a valid email.
    * @param String $form_id the id of the form on which this email was submitted. (Defaults to 0).
    * @return String a unique link to validate the email, reurns false if the $email is invalid.
    * @since 1.0
    */
    $link = get_otp_by_email_link($email, $form_id=0);
    ```

## 评价

此插件暂无评价。

## 贡献者及开发者

「OTP by Email for Contact Form 7」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ Aurovrata Venet ](https://profiles.wordpress.org/aurovrata/)

[帮助将「OTP by Email for Contact Form 7」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/otp-by-email)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/otp-by-email/)，查看
[SVN仓库](https://plugins.svn.wordpress.org/otp-by-email/)，或通过[RSS](https://plugins.trac.wordpress.org/log/otp-by-email/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/otp-by-email/)。

## 更新日志

#### 1.2.0

 * clarify the OTP tab settings and mail tag functionality.

#### 1.1.2

 * fix form ID field bug.

#### 1.1.1

 * changed location of action hook otp_by_email_unique_link_created and added nonce
   field as attribute.

#### 1.1.0

 * added action hook otp_by_email_unique_link_created
 * added nonce field in otp_by_email_validated filter hook attributes.

#### 1.0.1

 * fix display of tab in admin page.

## 额外信息

 *  版本 **1.2.0**
 *  最后更新：**3 年前**
 *  活跃安装数量 **70+**
 *  WordPress 版本 ** 4.4 或更高版本 **
 *  已测试的最高版本为 **6.2.9**
 *  PHP 版本 ** 5.6 或更高版本 **
 *  语言
 * [English (US)](https://wordpress.org/plugins/otp-by-email/)
 * 标签
 * [contact form 7 extension](https://cn.wordpress.org/plugins/tags/contact-form-7-extension/)
   [email validation](https://cn.wordpress.org/plugins/tags/email-validation/)[email verification](https://cn.wordpress.org/plugins/tags/email-verification/)
   [otp](https://cn.wordpress.org/plugins/tags/otp/)
 *  [高级视图](https://cn.wordpress.org/plugins/otp-by-email/advanced/)

## 评级

尚未提交反馈。

[Your review](https://wordpress.org/support/plugin/otp-by-email/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/otp-by-email/reviews/)

## 贡献者

 *   [ Aurovrata Venet ](https://profiles.wordpress.org/aurovrata/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/otp-by-email/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](https://www.paypal.com/donate?hosted_button_id=V6CMZPJSW7KXS)