Title: Force Login
Author: Kevin Vess
Published: <strong>2014 年 6 月 11 日</strong>
Last modified: 2025 年 2 月 7 日

---

搜尋外掛

![](https://ps.w.org/wp-force-login/assets/banner-772x250.png?rev=1768800)

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://ps.w.org/wp-force-login/assets/icon.svg?rev=1904031)

# Force Login

 由 [Kevin Vess](https://profiles.wordpress.org/kevinvess/) 開發

[下載](https://downloads.wordpress.org/plugin/wp-force-login.5.6.3.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/wp-force-login/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/wp-force-login/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/wp-force-login/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/wp-force-login/#developers)

 [技術支援](https://wordpress.org/support/plugin/wp-force-login/)

## 外掛說明

Easily hide your WordPress site from public viewing by requiring visitors to log
in first. As simple as flipping a switch.

Make your website private until it’s ready to share publicly, or keep it private
for members only.

**Features**

 * WordPress Multisite compatible.
 * Login redirects visitors back to the url they tried to visit.
 * Extensive Developer API (hooks & filters).
 * Customizable. Set a specific URL to always redirect to on login.
 * Filter exceptions for certain pages or posts.
 * Restrict REST API to authenticated users.
 * Translation Ready & WPML certified.

**Bug Reports**

Bug reports for [Force Login are welcomed on GitHub](https://github.com/kevinvess/wp-force-login).
Please note that GitHub is _not_ a support forum.

## 安裝方式

Upload the Force Login plugin to your site, then Activate it.

1, 2: You’re done!

## 常見問題集

### 1. How can I specify a redirect URL on login?

By default, the plugin sends visitors back to the URL they tried to access. However,
you can redirect users to a specific URL by adding the built-in WordPress filter
[login_redirect](https://developer.wordpress.org/reference/hooks/login_redirect/)
to your functions.php file.

### 2. How can I add exceptions for certain pages or posts?

You can bypass Force Login based on any condition by adding the following filter
to your functions.php file.

You may use the WordPress [Conditional Tags](https://developer.wordpress.org/themes/references/list-of-conditional-tags/)
in your code.

    ```
    /**
     * Bypass Force Login to allow for exceptions.
     *
     * @param bool $bypass Whether to disable Force Login. Default false.
     * @param string $visited_url The visited URL.
     * @return bool
     */
    function my_forcelogin_bypass( $bypass, $visited_url ) {

      // Allow 'My Page' to be publicly accessible
      if ( is_page('my-page') ) {
        $bypass = true;
      }

      return $bypass;
    }
    add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass', 10, 2 );
    ```

Check out the [Force Login Wiki on GitHub](https://github.com/kevinvess/wp-force-login/wiki)
for additional examples to allow URLs to be publicly accessible.

### 3. How do I hide the “ Back to {sitename}” link?

The WordPress login screen includes a “ Back to {sitename}” link below the login
form; which may not actually take you back to the site while Force Login is activated.
You can hide this link by adding the following action to your functions.php file.

**Requires:** WordPress 2.5 or higher

    ```
    // Hide the 'Back to {sitename}' link on the login screen.
    function my_forcelogin_hide_backtoblog() {
      echo '<style type="text/css">#backtoblog{display:none;}</style>';
    }
    add_action( 'login_enqueue_scripts', 'my_forcelogin_hide_backtoblog' );
    ```

## 使用者評論

![](https://secure.gravatar.com/avatar/280ce8da2d1be2e074c491f442a66a0710068a0857d52192c948f82ebd89de82?
s=60&d=retro&r=g)

### 󠀁[Short and sweet, does what you need](https://wordpress.org/support/topic/short-and-sweet-does-what-you-need/)󠁿

 [bkjproductions](https://profiles.wordpress.org/bkjproductions/) 2025 年 3 月 24
日

It is nice to find such an easy-to-use plugin, that also has a way alter with some
hooks, so if you don’t mind doing a little PHP you can specify certain pages can
be visible.

![](https://secure.gravatar.com/avatar/67a535c33c640eb0e3564f02f86573f854405d620c2c52f8930abc84b753c713?
s=60&d=retro&r=g)

### 󠀁[Just Works!](https://wordpress.org/support/topic/just-works-804/)󠁿

 [esyrett](https://profiles.wordpress.org/esyrett/) 2025 年 3 月 4 日

I used this plugin to implement a security fence around our Members area. It’s easy.
You have to have permalinks set up to include postname and then in the filter code
just filter on the pages that you need to be protected.

![](https://secure.gravatar.com/avatar/2575687b68f004ac334b350150c3a0fe3ae1872f5b07bcb28e082ee2d0ba9f73?
s=60&d=retro&r=g)

### 󠀁[Simply works fine <3](https://wordpress.org/support/topic/simply-works-fine-3/)󠁿

 [ucsendre](https://profiles.wordpress.org/ucsendre/) 2024 年 10 月 30 日

This plugin does what it is expected to do. No fancy extras, no bloat. Simply works.
I love it. Many thanks for the author.

![](https://secure.gravatar.com/avatar/2c1649f010c724b55c3a04b279e0b986ea0aaae3ce2e683959e476b0f9d1cf35?
s=60&d=retro&r=g)

### 󠀁[Great but needs upkeep](https://wordpress.org/support/topic/great-but-needs-upkeep/)󠁿

 [ahmad21](https://profiles.wordpress.org/ahmad21/) 2024 年 10 月 5 日

Love this plugin and has helped me hide websites until they are ready for public
viewing. But it needs regular more frequent updates! Compatibility/testing with 
the latest WordPress versions is important for site security etc.

![](https://secure.gravatar.com/avatar/0c547a27a20d73b867596760646c9b69f61999cd45a9f9349164445d87f34ac3?
s=60&d=retro&r=g)

### 󠀁[Simple and helpful](https://wordpress.org/support/topic/simple-and-helpful-44/)󠁿

 [ISHIHARA](https://profiles.wordpress.org/ishihara/) 2024 年 6 月 12 日

I find your plugin Force Login very useful and I love using it. Thank you very much.
This plugin helps me to easily start a private site that only I can see or a closed
site managed by a few members. I also love the fact that I can organize my members
by simply managing WordPress users.

![](https://secure.gravatar.com/avatar/f427129b135d68aef8e6ae1193356900ab6835e3adf19f4ce31bac4b1d0b4ded?
s=60&d=retro&r=g)

### 󠀁[Simple & Functional](https://wordpress.org/support/topic/simple-functional-23/)󠁿

 [pmiguet](https://profiles.wordpress.org/pmiguet/) 2024 年 4 月 4 日

Simple plugin, no fuss, works as promised. Such a simple function that could easily
be implemented but here we are, using a brilliant plugin. Thanks.

 [ 閱讀全部 102 則使用者評論 ](https://wordpress.org/support/plugin/wp-force-login/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Force Login〉的開發相關工作。

參與者

 *   [ Kevin Vess ](https://profiles.wordpress.org/kevinvess/)

〈Force Login〉外掛目前已有 14 個本地化語言版本。 感謝[全部譯者](https://translate.wordpress.org/projects/wp-plugins/wp-force-login/contributors)
為這個外掛做出的貢獻。

[將〈Force Login〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/wp-force-login)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/wp-force-login/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/wp-force-login/)，或透過 [RSS](https://plugins.trac.wordpress.org/log/wp-force-login/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/wp-force-login/)。

## 變更記錄

#### 5.6.3

 * Fix – Fixed issue for sites with a custom login URL.

#### 5.6.2

 * Fix – Fixed issue for sites with a custom login URL.

#### 5.6.1

 * Fix – Fixed too many redirects issue for Multisite users.

#### 5.6

 * Feature – Added filter for Multisite unauthorized error message.
 * Tweak – Allow logged-in Multisite users to access bypassed pages of other sites.

#### 5.5

 * Tweak – Deprecated whitelist filter, use v_forcelogin_bypass instead.

#### 5.4

 * Tweak – Improved the visited $url variable.
 * Tweak – Changed code to comply with WordPress standards – props [Alex Bordei](https://github.com/kevinvess/wp-force-login/pull/43).

#### 5.3

 * Feature – Added nocache_headers() to prevent caching for the different browsers–
   props [Chris Harmoney](https://github.com/kevinvess/wp-force-login/pull/42).
 * Tweak – Removed $url parameter from whitelist filter.

#### 5.2

 * Feature – Added $url parameter to bypass and whitelist filters.
 * Tweak – Updated Multisite conditionals which determine user access to sites.
 * Tweak – Moved ‘v_forcelogin_redirect’ filter to improve performance.

#### 5.1.1

 * Fix – Improved the REST API restriction to allow alternative modes of authentication.

#### 5.1

 * Tweak – Restrict access to the REST API for authorized users only – props [Andrew Duthie](https://github.com/kevinvess/wp-force-login/pull/34).
 * Tweak – Added load_plugin_textdomain() to properly prepare for localization at
   translate.wordpress.org.

#### 5.0

 * Feature – Added filter to bypass Force Login redirect for allowing pages without
   specifying a URL.
 * Tweak – Changed the hook for Force Login to run at a later stage in the WordPress
   tree.
 * Fix – Replaced deprecated function – props [Just-Johnny](https://github.com/kevinvess/wp-force-login/issues/26).

#### 4.2

 * Tweak – Made plugin translation ready.

#### 4.1

 * Fix – Multisite ‘Super Admin’ users do not need assigned sites to access the 
   network.

#### 4.0

 * Feature – Added exceptions for AJAX, Cron and WP-CLI requests.
 * Fix – Only allow Multisite users access to their assigned sites.

#### 3.3

 * Fix – Check for existence of explicit port number before appending port – props
   [Björn Ali Göransson](https://github.com/kevinvess/wp-force-login/pull/10).

#### 3.2

 * Tweak – Removed v_getUrl() function to reduce possible duplicates of global functions–
   props [Joachim Happel](https://github.com/johappel).

#### 3.1

 * Fix – Rewrote v_getUrl() function to use HTTP_HOST instead of SERVER_NAME – props
   [Arlen22](https://github.com/kevinvess/wp-force-login/issues/7).

#### 3.0

 * Feature – Added filter for the redirect URL on login.
 * Feature – Added filter to allow whitelisting of additional URLs.

#### 2.1

 * Fix – Rewrote v_getUrl function to include the server port – props [Nicolas](https://wordpress.org/support/topic/infinite-loop-when-server-port-is-not-standard/).

#### 2.0

 * Feature – Added redirect to send visitors back to the URL they tried to visit
   before logging in.

#### 1.3

 * Fix – Fixed password reset URL from being blocked – props [estebillan](https://wordpress.org/support/topic/password-reset-url-is-blocked/).

#### 1.2

 * Tweak – Streamlined code

#### 1.1

 * Fix – Allow access to the registration and the lost password page URLs – props
   [jabdo](https://profiles.wordpress.org/jabdo).

## 中繼資料

 *  版本 **5.6.3**
 *  最後更新 **1 年前**
 *  啟用安裝數 **30,000+**
 *  WordPress 版本需求 ** 4.6 或更新版本 **
 *  已測試相容的 WordPress 版本 **6.7.5**
 *  語言
 * [Chinese (Taiwan)](https://tw.wordpress.org/plugins/wp-force-login/)、[Czech](https://cs.wordpress.org/plugins/wp-force-login/)、
   [Dutch](https://nl.wordpress.org/plugins/wp-force-login/)、[English (Canada)](https://en-ca.wordpress.org/plugins/wp-force-login/)、
   [English (UK)](https://en-gb.wordpress.org/plugins/wp-force-login/)、[English (US)](https://wordpress.org/plugins/wp-force-login/)、
   [French (France)](https://fr.wordpress.org/plugins/wp-force-login/)、[German](https://de.wordpress.org/plugins/wp-force-login/)、
   [Italian](https://it.wordpress.org/plugins/wp-force-login/)、[Romanian](https://ro.wordpress.org/plugins/wp-force-login/)、
   [Slovak](https://sk.wordpress.org/plugins/wp-force-login/)、[Spanish (Chile)](https://cl.wordpress.org/plugins/wp-force-login/)、
   [Spanish (Mexico)](https://es-mx.wordpress.org/plugins/wp-force-login/)、[Spanish (Spain)](https://es.wordpress.org/plugins/wp-force-login/)、
   及 [Spanish (Venezuela)](https://ve.wordpress.org/plugins/wp-force-login/).
 *  [將這個外掛本地化為你的母語版本](https://translate.wordpress.org/projects/wp-plugins/wp-force-login)
 * 標籤:
 * [privacy](https://tw.wordpress.org/plugins/tags/privacy/)[private](https://tw.wordpress.org/plugins/tags/private/)
   [protected](https://tw.wordpress.org/plugins/tags/protected/)[registered only](https://tw.wordpress.org/plugins/tags/registered-only/)
   [restricted](https://tw.wordpress.org/plugins/tags/restricted/)
 *  [進階檢視](https://tw.wordpress.org/plugins/wp-force-login/advanced/)

## 評分

 4.8 星，滿分為 5 星

 *  [  95 個 5 星使用者評論     ](https://wordpress.org/support/plugin/wp-force-login/reviews/?filter=5)
 *  [  0 個 4 星使用者評論     ](https://wordpress.org/support/plugin/wp-force-login/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/wp-force-login/reviews/?filter=3)
 *  [  3 個 2 星使用者評論     ](https://wordpress.org/support/plugin/wp-force-login/reviews/?filter=2)
 *  [  3 個 1 星使用者評論     ](https://wordpress.org/support/plugin/wp-force-login/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/wp-force-login/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/wp-force-login/reviews/)

## 參與者

 *   [ Kevin Vess ](https://profiles.wordpress.org/kevinvess/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/wp-force-login/)

## 贊助

想要支援這個外掛的發展嗎？

 [ 贊助這個外掛 ](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=forcelogin%40vess%2eme&lc=US&item_name=Force%20Login%20for%20WordPress&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)