最近、あるユーザーからWordPress 4.5で導入されたメールでのログイン機能を無効化する方法を尋ねられました。
この機能により、ユーザーはログインフォームにユーザー名またはメールアドレスを入力してログインすることができます。
この投稿では、WordPressでメールアドレスによるログイン機能を無効化する方法を紹介します。
WordPressでメールログインを無効化する理由
ユーザーによっては、メールアドレスはユーザー名よりも常識だと考えている人もいる。誰かにメールを送れば、相手はすでにあなたのメールアドレスを知っている。
誰かがあなたのWordPressサイトに侵入しようとした場合、メールアドレスを知っていれば、パスワードを推測したり、メールアカウントをハッキングすることで、侵入が容易になる可能性があります。
私たちは、ログインにメールアドレスを使用することでWordPressサイトのセキュリティが低下するとは考えていません。WordPressの管理ディレクトリをパスワードで保護したり、二段階認証を追加するなど、セキュリティのレイヤーを増やすことはいつでもできます。
WordPressのセキュリティについては、すべてのサイトでSucuriを使用しています。Sucuriのおかげで3ヶ月で450,000件のWordPress攻撃をブロックできたことをご覧ください。
とはいえ、WordPressサイトでメールによるログイン機能を無効化したいユーザーもいることでしょう。簡単にできる方法を見てみましょう。
方法1.WordPressでコードを使用してメールによるログインを無効化する(推奨)
この方法では、WordPressファイルにコードを追加する必要があります。WordPressにスニペットを貼り付ける方法については、こちらをご覧ください。
メールでのログイン機能を無効化するには、テーマのfunctions.phpファイルまたはコードスニペットプラグインに次のコードを追加する必要があります。
remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 );
さらに簡単にするには、WordPressに最適なコード・スニペット・プラグインであるWPCodeを使うことができる。
WPCodeにはビルトインライブラリがあり、メールでのログイン無効化、WordPressのバージョン番号の削除、コメントする無効化など、WordPressで最も人気のある機能リクエストに対応するコードスニペットがすべて用意されています。
一番の利点は、テーマのfunctions.phpファイルをすべて編集する必要がないことだ。
開始するには、無料のWPCodeプラグインをインストールし、有効化する必要があります。ヘルプが必要な場合は、WordPressプラグインのインストール方法についてのチュートリアルをお読みください。
プラグインを有効化したら、WordPressの管理ダッシュボードからCode Snippets “Libraryにアクセスしてください。
次に、「Disable Login by Email」スニペットを検索し、「Use snippet」ボタンをクリックします。
その後、WPCodeは自動的にコード・スニペットを追加し、適切な挿入方法を選択します。
必要なのは、スイッチを「非アクティブ」から「有効化」に切り替えることだけだ。
そして「更新」ボタンをクリックする。
それだけだ!
これにより、ログインページでは何も変更されず、ユーザーはユーザー名またはメールアドレスのいずれかを使用してログインできることがわかります。しかし、メールアドレスを入力してログインすると、無効なユーザー名エラーが表示されます。
方法2.プラグインを使用してWordPressでメールによるログインを無効化する。
個別プラグインでメールによるログイン機能を無効化することもできます。
最初に行う必要があるのは、No Login by Email Addressプラグインをインストールして有効化することです。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。
プラグインは箱から出してすぐに使えますし、設定も必要ありません。WordPressサイトのログイン画面にアクセスし、メールアドレスでログインしてみてください。
無効なユーザー名エラーが表示されます。プラグインはまた、「ユーザー名またはメール・アドレス」というラベルを単に「ユーザー名」に変更します。
以上、この投稿がWordPressのメールアドレスでのログイン機能を無効化するのにお役に立てば幸いです。WordPressのログインエラーメッセージでログインヒントを無効化する方法や、WordPressのログインページプラグインのおすすめもご覧ください。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
momses says
Hi,
Thanks for you article. I’m looking for a way to Login only By mail no Username.
Thanks in advance for you help.
Dom WO says
Does this article also cover the registration form in woocommerce for the customers or it is only for the admin side login ?
Debra says
Somehow it isn’t clear to me how to add a username once the email address login is disabled. Can you please explain.
Thanks so much
WPBeginner Support says
If you have user registration enabled on your site, then those users can still register using their email addresses. But they will not be able to use the email address to login. They will have to use the username to login. As an administrator, you will also need to enter an email and user name when adding a new user.
管理者
Abdul Samad says
Thank you for article
I want to know, how to allow login with mobile number
Second, I want to register my customer without email in wordpress
Please help me out with this
Thanks
Jeramy Queale says
I simply couldn’t go away your website prior to suggesting that I really loved the usual information an individual provide in your visitors? Is gonna be back frequently to check up on new posts
Jayna Coppedge says
I have a login to my wordpress blog. I have a different login for another wordpress blog I write with others. However when I want to comment on another wordpress blog. Neither user name or password works. I have not been willing to say change this long in because I am afraid it would affect the other 2. I don’t know what to call the 3 category to even look up the problem.
WPBeginner Support says
We are not sure what you are trying to ask. But it seems like you probably have two self hosted WordPress.org accounts. And the websites you are trying to comment on are asking you to sign in with a WordPress.com account. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
管理者