WordPressのパスワードリセットオプションを削除したいですか?
WordPressの初期設定では、ユーザーがメールアドレスを提供することでパスワードをリセット/変更できるようになっています。ハッカーがサイトに侵入しようとするのを防ぐために、WordPressのパスワードリセットオプションを無効化したい場合があります。
この投稿では、WordPressからパスワードリセット/変更オプションを削除する方法を紹介します。
なぜWordPressからパスワードリセット/変更オプションを削除するのか?
WordPressサイトでユーザー登録を許可している場合、パスワードリセットオプションにより、ユーザーは紛失したパスワードを回復することができます。通常、このオプションは変更したくありません。
しかし、利用シーンによっては、WordPressサイトの特定のユーザーやユーザー権限グループに対して、このオプションを削除したい場合があります。
例えば、誰かのために一時的なアカウントを作成したり、ユーザーがデモ用のユーザー名とパスワードでログインできるデモサイトを作成した場合です。
また、パスワードリセットオプションを設定することは、ハッカーにサイトへの侵入を試みる別の方法を与えることになります。WordPressのセキュリティが特に心配な場合は、ユーザーが自分でパスワードをリセットできるオプションを削除することをお勧めします。
より簡単な解決策は、パスワードリセットリンクを削除することでしょう。しかし、経験豊富なユーザーの中には、パスワードリセットフォームにアクセスするためのURLをすでに知っている人もいるでしょう。
とはいえ、WordPressからパスワードリセット/変更オプションを簡単に削除する方法を見てみましょう:
方法1:LoginPressを使用してパスワードリセット/変更オプションを無効化する。
パスワードリセット/変更オプションを無効化する最も簡単な方法は、LoginPressを使用することです。ログインページをカスタマイズできる無料のWordPressプラグインです。
LoginPressは、ログインページの外観をカスタマイズすることで、セキュリティやページの見栄えを向上させる様々な機能を提供しています。
ステップ1:LoginPressのインストールと有効化
まずはLoginPressをインストールして有効化してください。詳しくは、WordPressプラグインのインストール方法のチュートリアルをご覧ください。
注: 無料版には、パスワードリセット/変更オプションを無効化するために必要なものがすべて揃っています。とはいえ、有料版にはログインURLのカスタマイザーやログイン試行の制限など、高度なセキュリティ機能があります。
ステップ2:設定のカスタマイズ
次に、WordPressダッシュボードからLoginPress ” 設定ページに移動します。設定ページには、ログインページをカスタマイズするためのオプションがたくさんあります。他のタブの多くは有料機能ですが、設定オプションは無料ユーザーでも利用できます。
おそらくオンにしておきたいのが、’Force Password Reset’オプションです。このオプションを設定したら、ユーザーが再度パスワードを変更するまでの期間を日数で設定する必要があります。
WordPressのセキュリティ上の目安は、90日ごとにパスワードを変更することです。また、このパスワードリセットルールを適用するユーザー権限を選択することもできます。
その下には、セッションの有効期限が切れる前に、ユーザーがWordPressサイトのバックエンドにアクセスできる時間を設定することもできます。さらに、ユーザー登録フォームにカスタマイザーパスワードフィールドを追加することもできます。
カスタマイズしたいオプションをすべて設定したら、「変更を保存」ボタンを押してください。
ステップ3:パスワード忘れ無効化
ここから、LoginPress “ カスタマイザーに進みます。ビルトインエディターが表示され、WordPressのログインページを簡単にカスタマイズすることができます。
パスワードをお忘れですか?’ メッセージを削除するには、フォームフッタータブに移動する必要があります。パスワードをお忘れですか?’ の隣にある鉛筆アイコンをクリックしても、フォームフッタータブに移動できます。
次に、「フッターテキストを有効化」オプションをオフにする必要がある。
これにより、ログインページから「登録」と「パスワードをお忘れですか」のオプションが削除されます。
このプラグインは他にもたくさんのクールな機能を提供している。
例えば、ボタンの色やテキストの色を変更したり、ロゴを追加したり、背景を変更することもできます。変更したい場所の鉛筆アイコンをクリックするか、左サイドパネルからナビゲートするだけです。
WordPressログインページのカスタマイザーが完了したら、変更を保存します。
左上にある「公開する」ボタンを押すだけで、変更が確定します。
最後に、WordPressダッシュボードからログアウトする必要があります。その後、再度ログインしてみて、パスワード紛失のオプションが表示されなくなったことを確認してください。
これでWordPressからパスワードリセット/変更オプションを削除することに成功しました。
方法2:WPCodeを使用してWordPressからパスワードリセットオプションを手動で無効化する
この方法では、WordPressサイトにコードを追加する必要があります。
チュートリアルの中には、ファイルを直接編集するように指示するものもありますが、これはお勧めしません。コードタイプ中の小さなエラーでさえ、WordPressのエラーを引き起こしたり、サイトにアクセスできなくなる可能性があります。
そのため、代わりにWPCodeのようなコードスニペットプラグインを使用することをお勧めします。
この人気のプラグインを使えば、テーマのfunctions.phpファイルを編集することなくWordPressにカスタムコードを追加できるので、サイトが壊れる心配がない。
このチュートリアルでは、WPCodeの無料版を使用することができます。しかし、プレミアムバージョンにアップグレードすると、より多くの既製のスニペットや、コードジェネレータ、リビジョン履歴、スマート条件ロジックなどの高度な機能を利用できるようになります。
開始するには、WPCodeプラグインをインストールし、有効化する必要があります。詳しくは、WordPressプラグインのインストール方法をご覧ください。
次に、コード・スニペット ” + スニペットを追加.
パスワードリセットオプションを無効化するための既製のスニペットはありませんので、カスタムコードを追加する必要があります。
Add Your Custom Code」バーにマウスオーバーし、「Use Snippet」をクリックします。
まず、カスタム・スニペットに名前をつける必要がある。
そうすれば、後で変更が必要になったときに参照することができる。
次に、コードタイプのドロップダウンメニューから「PHP Snippet」オプションを選択します。
次に、以下のコードをコピー&ペーストして、コードプレビューのテキストエディターに貼り付けます:
<?php
/*
* Plugin Name: Disable Password Reset
* Description: Disable password reset functionality. Only users with administrator role will be able to change passwords from inside admin area.
* Version: 1.0
* Author: WPBeginner
* Author URI: http://wpbeginner.com
*/
class Password_Reset_Removed
{
function __construct()
{
add_filter( 'show_password_fields', array( $this, 'disable' ) );
add_filter( 'allow_password_reset', array( $this, 'disable' ) );
add_filter( 'gettext', array( $this, 'remove' ) );
}
function disable()
{
if ( is_admin() ) {
$userdata = wp_get_current_user();
$user = new WP_User($userdata->ID);
if ( !empty( $user->roles ) && is_array( $user->roles ) && $user->roles[0] == 'administrator' )
return true;
}
return false;
}
function remove($text)
{
return str_replace( array('Lost your password?', 'Lost your password'), '', trim($text, '?') );
}
}
$pass_reset_removed = new Password_Reset_Removed();
?>
画面はこのようになっているはずだ:
ここからは、ページ上部のオプションを「非有効化」から「有効化」に切り替えるだけでよい。
その後、「スニペットを保存」をクリックして変更を確定する。
準備はすべて整った。
これで、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!
Billy says
The Script you wrote on the top Method 2: Manually Disable Password Reset Option From WordPress. Is this still good ? Does it need to be updated ?
WPBeginner Support says
The second method in our article should still work unless we hear otherwise.
管理者
CG says
Hi,
how to remove all the other Options from the user-page?
WPBeginner Support says
While we don’t have a tutorial for that at the moment, for what it sounds like you’re wanting you may want to take a look at our guide on How to Limit Dashboard Access
管理者
Rich Adams says
Creating the plugin works perfectly, thank you.
Hoowever the Security plugin WordFence shows a warning now:
“The Plugin “Disable Password Reset” appears to be abandoned (updated November 10, 2016, tested to WP 4.6.12).
Type: Plugin Abandoned”
Is there a way to update this plugin to avoid the warning?
TIA!
WPBeginner Support says
Hi Rich,
Try changing plugin name in the code.
管理者
Francine Paino says
I am a member of a writing organization and unfortunately, the member who was in charge of our website died suddenly. No one knows the password. We have created a new website on WordPress, but we need to take down the old one. Having two sites is causing a great deal of confusion.
How do we bypass the password? Is there someone to contact regarding this problem?
Thank you in advance for your assistance with this problem.
FP
WPBeginner Support says
Hi Francine,
If the old website is a self hosted WordPress.org website, then it is hosted by a hosting company. You can request the hosting company to take down the website. However, hosting companies usually do this only when the request is made by a deceased customer’s next of kin or someone with legal rights.
管理者
Imer García says
That’s still works with the recent versions of WP? Because Im just do it in 2 hosted in my local machine, and nothing happens. The plugin is installed and activated, but the “Forgot Your Password” option remains in the login form.
Thanks
Kristi Buchanan says
I recently got a new computer and I need to know how disable the password to be able to get into it so I can finish setting it up?
Lo says
Great! thank you
Priya Singh says
Hi Team,
This is extremely fantastic tutorial you have shared on this amazing blog because i was thinking to try it through my dashboard but i was unable to do and when i visited on this awesome WPbeginner site and i found it.
so in this case thanks a lot .
Saeed Khan says
The plugin generated 3 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
Please help how to fixed this issue??
WPBeginner Support says
If you are using the code method, then this could mean that there is extra space after php closing tag. You can delete those extra spaces, you can also delete the PHP closing tag ?>
管理者
Adam Edgar says
that doesnt remove my error message
“The plugin generated 1 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.”