Version Description
- Added hook to set a specific URL to redirect to on login.
- Added hook to allow whitelisting of additional URLs.
Download this release
Release Info
Developer | kevinvess |
Plugin | Force Login |
Version | 3.0 |
Comparing to | |
See all releases |
Code changes from version 2.1 to 3.0
- readme.txt +84 -9
- wp-force-login.php +8 -4
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: kevinvess
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kevin%40vess%2eme&lc=US&item_name=Kevin%20Vess%20-%20WordPress¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
|
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.
|
7 |
-
Stable tag:
|
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.
|
@@ -16,6 +16,18 @@ Easily hide your WordPress site from public viewing by requiring visitors to log
|
|
16 |
|
17 |
Make your website private until it's ready to share publicly, or keep it private for members only.
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
== Installation ==
|
21 |
|
@@ -24,28 +36,91 @@ Upload the Force Login plugin to your site, then Activate it.
|
|
24 |
1, 2: You're done!
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
== Changelog ==
|
28 |
|
|
|
|
|
|
|
|
|
29 |
= 2.1 =
|
30 |
-
|
31 |
|
32 |
= 2.0 =
|
33 |
-
|
34 |
|
35 |
= 1.3 =
|
36 |
-
|
37 |
|
38 |
= 1.2 =
|
39 |
-
|
40 |
|
41 |
= 1.1 =
|
42 |
-
|
43 |
|
44 |
|
45 |
== Upgrade Notice ==
|
46 |
|
|
|
|
|
|
|
47 |
= 2.0 =
|
48 |
-
New feature: added redirect to send
|
49 |
|
50 |
= 1.3 =
|
51 |
-
Fixes bug with password reset
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kevin%40vess%2eme&lc=US&item_name=Kevin%20Vess%20-%20WordPress¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
|
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.
|
16 |
|
17 |
Make your website private until it's ready to share publicly, or keep it private for members only.
|
18 |
|
19 |
+
**Features**
|
20 |
+
|
21 |
+
- WordPress Multisite compatible.
|
22 |
+
- Login redirects visitors back to the url they tried to visit.
|
23 |
+
- Extensive Developer API (hooks & filters).
|
24 |
+
- Customizable. Set a specific URL to always redirect to on login
|
25 |
+
- Filter exceptions for certain pages or posts.
|
26 |
+
|
27 |
+
**Bug Reports**
|
28 |
+
|
29 |
+
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.
|
30 |
+
|
31 |
|
32 |
== Installation ==
|
33 |
|
36 |
1, 2: You're done!
|
37 |
|
38 |
|
39 |
+
== Frequently Asked Questions ==
|
40 |
+
|
41 |
+
= How can I specify a URL to redirect to on login? =
|
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 |
+
/**
|
49 |
+
* Set the URL to redirect to on login.
|
50 |
+
*
|
51 |
+
* @return string URL to redirect to on login. Must be absolute.
|
52 |
+
**/
|
53 |
+
function my_forcelogin_redirect() {
|
54 |
+
return site_url( '/mypage/' );
|
55 |
+
}
|
56 |
+
add_filter('v_forcelogin_redirect', 'my_forcelogin_redirect', 10, 1);
|
57 |
+
`
|
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 |
+
/**
|
65 |
+
* Filter Force Login to allow exceptions for specific URLs.
|
66 |
+
*
|
67 |
+
* @return array An array of URLs. Must be absolute.
|
68 |
+
**/
|
69 |
+
function my_forcelogin_whitelist( $whitelist ) {
|
70 |
+
$whitelist[] = site_url( '/mypage/' );
|
71 |
+
$whitelist[] = site_url( '/2015/03/post-title/' );
|
72 |
+
return $whitelist;
|
73 |
+
}
|
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.
|
100 |
+
|
101 |
= 2.1 =
|
102 |
+
- Rewrote v_getUrl function to include the server port - props [Nicolas](http://profiles.wordpress.org/nottavi).
|
103 |
|
104 |
= 2.0 =
|
105 |
+
- Added redirect to send visitors back to the URL they tried to visit after logging in.
|
106 |
|
107 |
= 1.3 =
|
108 |
+
- Fixed password reset URL from being blocked - props [estebillan](http://profiles.wordpress.org/estebillan).
|
109 |
|
110 |
= 1.2 =
|
111 |
+
- Streamlined code
|
112 |
|
113 |
= 1.1 =
|
114 |
+
- Whitelisted the registration page and the Lost Password page - props [jabdo](http://profiles.wordpress.org/jabdo).
|
115 |
|
116 |
|
117 |
== Upgrade Notice ==
|
118 |
|
119 |
+
= 3.0 =
|
120 |
+
New features: added developer hooks for customizing the plugin.
|
121 |
+
|
122 |
= 2.0 =
|
123 |
+
New feature: added redirect to send visitors back to the URL they tried to visit after logging in.
|
124 |
|
125 |
= 1.3 =
|
126 |
+
Fixes bug with password reset URL from being blocked.
|
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:
|
7 |
Author: Kevin Vess
|
8 |
Author URI: http://vess.me/
|
9 |
License: GPLv2 or later
|
@@ -33,9 +33,13 @@ function v_getUrl() {
|
|
33 |
return $url;
|
34 |
}
|
35 |
function v_forcelogin() {
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
}
|
41 |
add_action('init', 'v_forcelogin');
|
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
|
33 |
return $url;
|
34 |
}
|
35 |
function v_forcelogin() {
|
36 |
+
if( !is_user_logged_in() ) {
|
37 |
+
$url = v_getUrl();
|
38 |
+
$whitelist = apply_filters('v_forcelogin_whitelist', array());
|
39 |
+
$redirect_url = apply_filters('v_forcelogin_redirect', $url);
|
40 |
+
if( preg_replace('/\?.*/', '', $url) != preg_replace('/\?.*/', '', wp_login_url()) && !in_array($url, $whitelist) ) {
|
41 |
+
wp_safe_redirect( wp_login_url( $redirect_url ), 302 ); exit();
|
42 |
+
}
|
43 |
}
|
44 |
}
|
45 |
add_action('init', 'v_forcelogin');
|