0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

memberpressでメールを2回入力させる

Posted at

#目的
memberpressでメール確認のためにメルアド二回入力させたい時のメモ。
フックとかでも直せるのかもしれないが、わとりあえずその場しのぎだが、プラグインを直接編集して対応。

#サインアップのテンプレートの修正
メール確認のフォームを追加します。

wp-content/plugins/memberpress/app/views/checkout/form.php
      <!-- 前半省略(変更なし)  -->
      <!-- input要素にmepr_emailクラスを追加した以外へんこうなし -->
       <div class="mp-form-row mepr_email">
        <div class="mp-form-label">
          <label for="user_email<?php echo $unique_suffix; ?>"><?php _ex('Email:*', 'ui', 'memberpress'); ?></label>
          <span class="cc-error"><?php _ex('Invalid Email', 'ui', 'memberpress'); ?></span>
        </div>
        <input type="email" name="user_email" id="user_email<?php echo $unique_suffix; ?>" class="mepr-form-input mepr-email-input" value="<?php echo (isset($user_email))?esc_attr(stripslashes($user_email)):''; ?>" required />
      </div>
      <!-- ↓↓↓↓↓メール確認のフォームを追加 -->
      <div class="mp-form-row mepr_email_confirm">
        <div class="mp-form-label">
          <label for="user_email_confirm<?php echo $unique_suffix; ?>"><?php _ex('Email Confirmation:*', 'ui', 'memberpress'); ?></label>
          <span class="cc-error"><?php _ex('Email Confirmation Doesn\'t Match', 'ui', 'memberpress'); ?></span>
        </div>
        <input type="email" name="user_email_confirm" id="user_email_confirm<?php echo $unique_suffix; ?>" class="mepr-form-input mepr-email-confirm-input" value="<?php echo (isset($user_email_confirm))?esc_attr(stripslashes($user_email_confirm)):''; ?>" required />
      </div>
      <!-- ↑↑↑↑↑↑メール確認のフォームを追加 -->
      <!-- 以下略(変更なし) -->

#サインアップのjavascriptのバリデーションの修正
2つのメルアドが一致してるときだけ送信できるようにします。

wp-content/plugins/memberpress/js/signup.js
//前半省略(変更なし)
if ($(obj).attr('type')==='url' && $(obj).val().length > 0) {
        var validURL = $(obj).is(':valid');
        mpToggleFieldValidation($(obj), validURL);
      }
      //追加部分↓↓
      if ($(obj).hasClass('mepr-email-confirm-input')) {
        var confirmMatch = $(obj).val() === form.find('.mepr-email-input').val();
        mpToggleFieldValidation($(obj), confirmMatch);
      }
      //追加部分ここまで↑↑
      if ($(obj).hasClass('mepr-password-confirm')) {
        var confirmMatch = $(obj).val() === form.find('.mepr-password').val();
        mpToggleFieldValidation($(obj), confirmMatch);
      }
      //途中省略(変更なし)
}
//以下省略(変更なし)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?