Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressからパスワードリセット/変更オプションを削除する方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

WordPressのパスワードリセットオプションを削除したいですか?

WordPressの初期設定では、ユーザーがメールアドレスを提供することでパスワードをリセット/変更できるようになっています。ハッカーがサイトに侵入しようとするのを防ぐために、WordPressのパスワードリセットオプションを無効化したい場合があります。

この投稿では、WordPressからパスワードリセット/変更オプションを削除する方法を紹介します。

Remove the password reset option in WordPress

なぜWordPressからパスワードリセット/変更オプションを削除するのか?

WordPressサイトでユーザー登録を許可している場合、パスワードリセットオプションにより、ユーザーは紛失したパスワードを回復することができます。通常、このオプションは変更したくありません。

しかし、利用シーンによっては、WordPressサイトの特定のユーザーやユーザー権限グループに対して、このオプションを削除したい場合があります。

例えば、誰かのために一時的なアカウントを作成したり、ユーザーがデモ用のユーザー名とパスワードでログインできるデモサイトを作成した場合です。

また、パスワードリセットオプションを設定することは、ハッカーにサイトへの侵入を試みる別の方法を与えることになります。WordPressのセキュリティが特に心配な場合は、ユーザーが自分でパスワードをリセットできるオプションを削除することをお勧めします。

より簡単な解決策は、パスワードリセットリンクを削除することでしょう。しかし、経験豊富なユーザーの中には、パスワードリセットフォームにアクセスするためのURLをすでに知っている人もいるでしょう。

とはいえ、WordPressからパスワードリセット/変更オプションを簡単に削除する方法を見てみましょう:

方法1:LoginPressを使用してパスワードリセット/変更オプションを無効化する。

パスワードリセット/変更オプションを無効化する最も簡単な方法は、LoginPressを使用することです。ログインページをカスタマイズできる無料のWordPressプラグインです。

LoginPress

LoginPressは、ログインページの外観をカスタマイズすることで、セキュリティやページの見栄えを向上させる様々な機能を提供しています。

ステップ1:LoginPressのインストールと有効化

まずはLoginPressをインストールして有効化してください。詳しくは、WordPressプラグインのインストール方法のチュートリアルをご覧ください。

注: 無料版には、パスワードリセット/変更オプションを無効化するために必要なものがすべて揃っています。とはいえ、有料版にはログインURLのカスタマイザーやログイン試行の制限など、高度なセキュリティ機能があります。

ステップ2:設定のカスタマイズ

次に、WordPressダッシュボードからLoginPress ” 設定ページに移動します。設定ページには、ログインページをカスタマイズするためのオプションがたくさんあります。他のタブの多くは有料機能ですが、設定オプションは無料ユーザーでも利用できます。

おそらくオンにしておきたいのが、’Force Password Reset’オプションです。このオプションを設定したら、ユーザーが再度パスワードを変更するまでの期間を日数で設定する必要があります。

WordPressのセキュリティ上の目安は、90日ごとにパスワードを変更することです。また、このパスワードリセットルールを適用するユーザー権限を選択することもできます。

enforce password reset

その下には、セッションの有効期限が切れる前に、ユーザーがWordPressサイトのバックエンドにアクセスできる時間を設定することもできます。さらに、ユーザー登録フォームにカスタマイザーパスワードフィールドを追加することもできます。

カスタマイズしたいオプションをすべて設定したら、「変更を保存」ボタンを押してください。

save changes in loginpress

ステップ3:パスワード忘れ無効化

ここから、LoginPress “ カスタマイザーに進みます。ビルトインエディターが表示され、WordPressのログインページを簡単にカスタマイズすることができます。

パスワードをお忘れですか?’ メッセージを削除するには、フォームフッタータブに移動する必要があります。パスワードをお忘れですか?’ の隣にある鉛筆アイコンをクリックしても、フォームフッタータブに移動できます。

form footer in loginpress

次に、「フッターテキストを有効化」オプションをオフにする必要がある。

これにより、ログインページから「登録」と「パスワードをお忘れですか」のオプションが削除されます。

disable footer text

このプラグインは他にもたくさんのクールな機能を提供している。

例えば、ボタンの色やテキストの色を変更したり、ロゴを追加したり、背景を変更することもできます。変更したい場所の鉛筆アイコンをクリックするか、左サイドパネルからナビゲートするだけです。

login page example

WordPressログインページのカスタマイザーが完了したら、変更を保存します。

左上にある「公開する」ボタンを押すだけで、変更が確定します。

publish login page

最後に、WordPressダッシュボードからログアウトする必要があります。その後、再度ログインしてみて、パスワード紛失のオプションが表示されなくなったことを確認してください。

これでWordPressからパスワードリセット/変更オプションを削除することに成功しました。

remove password reset example

方法2:WPCodeを使用してWordPressからパスワードリセットオプションを手動で無効化する

この方法では、WordPressサイトにコードを追加する必要があります。

チュートリアルの中には、ファイルを直接編集するように指示するものもありますが、これはお勧めしません。コードタイプ中の小さなエラーでさえ、WordPressのエラーを引き起こしたり、サイトにアクセスできなくなる可能性があります。

そのため、代わりにWPCodeのようなコードスニペットプラグインを使用することをお勧めします。

wpcode plugin

この人気のプラグインを使えば、テーマのfunctions.phpファイルを編集することなくWordPressにカスタムコードを追加できるので、サイトが壊れる心配がない。

このチュートリアルでは、WPCodeの無料版を使用することができます。しかし、プレミアムバージョンにアップグレードすると、より多くの既製のスニペットや、コードジェネレータ、リビジョン履歴、スマート条件ロジックなどの高度な機能を利用できるようになります。

開始するには、WPCodeプラグインをインストールし、有効化する必要があります。詳しくは、WordPressプラグインのインストール方法をご覧ください。

次に、コード・スニペット ” + スニペットを追加.

パスワードリセットオプションを無効化するための既製のスニペットはありませんので、カスタムコードを追加する必要があります。

Add Your Custom Code」バーにマウスオーバーし、「Use Snippet」をクリックします。

add custom code snippet

まず、カスタム・スニペットに名前をつける必要がある。

そうすれば、後で変更が必要になったときに参照することができる。

name custom code 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();
?>

画面はこのようになっているはずだ:

add remove password code snippet

ここからは、ページ上部のオプションを「非有効化」から「有効化」に切り替えるだけでよい。

その後、「スニペットを保存」をクリックして変更を確定する。

save snippet

準備はすべて整った。

これで、WordPressの管理エリアからログアウトできるので、パスワード再設定オプションが削除されているかどうかを確認できます。

remove password from wordpress login example

この投稿が、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.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

16件のコメント返信を残す

  1. 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!

  2. 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.

      管理者

  3. 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!

  4. 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.

      管理者

  5. 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 :)

  6. 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?

  7. 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 .

  8. 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.”

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。