Force Login - Version 3.1

Version Description

  • Rewrote v_getUrl function to use HTTP_HOST instead of SERVER_NAME - props Arlen22.
Download this release

Release Info

Developer kevinvess
Plugin Icon 128x128 Force Login
Version 3.1
Comparing to
See all releases

Code changes from version 3.0 to 3.1

Files changed (2) hide show
  1. readme.txt +6 -20
  2. wp-force-login.php +2 -2
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kevin
4
  Tags: access, closed, force user login, hidden, login, password, privacy, private, protected, registered only, restricted
5
  Requires at least: 2.7
6
  Tested up to: 4.2
7
- Stable tag: 3.0
8
  License: GPLv2 or later
9
 
10
  Force Login is a simple lightweight plugin that requires visitors to log in to interact with the website.
@@ -42,7 +42,7 @@ Upload the Force Login plugin to your site, then Activate it.
42
 
43
  By default, the plugin sends visitors back to the URL they tried to visit. However, you can set a specific URL to always redirect users to by adding the following filter to your functions.php file.
44
 
45
- The URL must be absolute (as in, `http://example.com/mypage/`). Recommended: [site_url( '/mypage/' )](https://codex.wordpress.org/Function_Reference/site_url).
46
 
47
  `
48
  /**
@@ -58,7 +58,7 @@ add_filter('v_forcelogin_redirect', 'my_forcelogin_redirect', 10, 1);
58
 
59
  = How can I add exceptions for certain pages or posts? =
60
 
61
- You can specify an array of URLs to whitelist by adding the following filter to your functions.php file. Each URL must be absolute (as in, `http://example.com/mypage/`). Recommended: [site_url( '/mypage/' )](https://codex.wordpress.org/Function_Reference/site_url).
62
 
63
  `
64
  /**
@@ -74,26 +74,12 @@ function my_forcelogin_whitelist( $whitelist ) {
74
  add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
75
  `
76
 
77
- = How do I get the WordPress mobile app to work? =
78
-
79
- By default, the plugin blocks access to all page URLs; you will need to whitelist the XML-RPC page to allow the WordPress app to access your site for remote publishing.
80
-
81
- `
82
- /**
83
- * Filter Force Login to allow exceptions for specific URLs.
84
- *
85
- * @return array An array of URLs. Must be absolute.
86
- **/
87
- function my_forcelogin_whitelist( $whitelist ) {
88
- $whitelist[] = site_url( '/xmlrpc.php' );
89
- return $whitelist;
90
- }
91
- add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
92
- `
93
-
94
 
95
  == Changelog ==
96
 
 
 
 
97
  = 3.0 =
98
  - Added hook to set a specific URL to redirect to on login.
99
  - Added hook to allow whitelisting of additional URLs.
4
  Tags: access, closed, force user login, hidden, login, password, privacy, private, protected, registered only, restricted
5
  Requires at least: 2.7
6
  Tested up to: 4.2
7
+ Stable tag: 3.1
8
  License: GPLv2 or later
9
 
10
  Force Login is a simple lightweight plugin that requires visitors to log in to interact with the website.
42
 
43
  By default, the plugin sends visitors back to the URL they tried to visit. However, you can set a specific URL to always redirect users to by adding the following filter to your functions.php file.
44
 
45
+ The URL must be absolute (as in, http://example.com/mypage/). Recommended: site_url( '/mypage/' ).
46
 
47
  `
48
  /**
58
 
59
  = How can I add exceptions for certain pages or posts? =
60
 
61
+ You can specify an array of URLs to whitelist by adding the following filter to your functions.php file. Each URL must be absolute (as in, http://example.com/mypage/). Recommended: site_url( '/mypage/' ).
62
 
63
  `
64
  /**
74
  add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
75
  `
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  == Changelog ==
79
 
80
+ = 3.1 =
81
+ - Rewrote v_getUrl function to use HTTP_HOST instead of SERVER_NAME - props [Arlen22](https://github.com/Arlen22).
82
+
83
  = 3.0 =
84
  - Added hook to set a specific URL to redirect to on login.
85
  - Added hook to allow whitelisting of additional URLs.
wp-force-login.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Force Login
4
  Plugin URI: http://vess.me/
5
  Description: Easily hide your WordPress site from public viewing by requiring visitors to log in first. Activate to turn on.
6
- Version: 3.0
7
  Author: Kevin Vess
8
  Author URI: http://vess.me/
9
  License: GPLv2 or later
@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
 
28
  function v_getUrl() {
29
  $url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
30
- $url .= '://' . $_SERVER['SERVER_NAME'];
31
  $url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
32
  $url .= $_SERVER['REQUEST_URI'];
33
  return $url;
3
  Plugin Name: Force Login
4
  Plugin URI: http://vess.me/
5
  Description: Easily hide your WordPress site from public viewing by requiring visitors to log in first. Activate to turn on.
6
+ Version: 3.1
7
  Author: Kevin Vess
8
  Author URI: http://vess.me/
9
  License: GPLv2 or later
27
 
28
  function v_getUrl() {
29
  $url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
30
+ $url .= '://' . $_SERVER['HTTP_HOST'];
31
  $url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
32
  $url .= $_SERVER['REQUEST_URI'];
33
  return $url;