WordPress Access Control - Version 3.1.4

Version Description

  • August 30, 2012 =

  • Added not/or keywords to the role option of the members shortcode, syntax: [members role="not:guest,banned"][/members] and members role="or:editor,author,contributor"

Download this release

Release Info

Developer brandon.wamboldt
Plugin Icon wp plugin WordPress Access Control
Version 3.1.4
Comparing to
See all releases

Code changes from version 3.1.3 to 3.1.4

documentation/assets/css/readme.css CHANGED
@@ -44,10 +44,10 @@ padding:0 0 7px;
44
 
45
  h2 {
46
  font-size:16px;
47
- border-bottom:1px solid #dadada;
48
- color:#666;
49
  font-weight: 100;
50
- padding:0 0 4px;
51
  }
52
 
53
  p, li, dd, dt {
@@ -225,4 +225,22 @@ border:1px solid #e6db55;
225
  background-color:#ffffe0;
226
  margin:5px 0 15px;
227
  padding:.3em .6em;
228
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  h2 {
46
  font-size:16px;
47
+ border-bottom:1px solid #dadada;
48
+ color:#666;
49
  font-weight: 100;
50
+ padding:0 0 4px;
51
  }
52
 
53
  p, li, dd, dt {
225
  background-color:#ffffe0;
226
  margin:5px 0 15px;
227
  padding:.3em .6em;
228
+ }
229
+
230
+ pre {
231
+ border-left: 5px solid #bbb;
232
+ font-size: 12px;
233
+ margin: 0 0 30px;
234
+ padding: 2px 0 2px 15px;
235
+ }
236
+ code, pre, tt {
237
+ font-family: Monaco,Consolas,"Lucida Console",monospace;
238
+ font-size: 12px;
239
+ font-style: normal;
240
+ line-height: 18px;
241
+ }
242
+ xmp, pre, plaintext {
243
+ display: block;
244
+ margin: 1em 0;
245
+ white-space: pre;
246
+ }
documentation/index.html CHANGED
@@ -215,15 +215,40 @@
215
  <h1 id="shortcodes">E) Shortcodes - <a href="#toc">top</a></h1>
216
 
217
  <p>
218
- There are two shortcodes available for use with this plugin.<br /><br />
 
219
 
 
 
 
220
  [members][/members] will hide the content within them unless the user is
221
  authenticated. Also works during searching, so that if a user searches for
222
  a term found in the shortcodes, but is not logged in, the page/post will
223
- not show up in the results. This shortcode also has an option to specify
224
- a specific role, using the syntax [members role="rolename"][/members].
225
  </p>
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  <p>
228
  [nonmembers][/nonmembers] will hide the content within them unless the user is
229
  not authenticated. Also works during searching, so that if a user searches for
@@ -289,6 +314,12 @@
289
 
290
  <h1 id="changelog">I) Changelog - <a href="#toc">top</a></h1>
291
 
 
 
 
 
 
 
292
  <p><strong>Version 3.1.3 - August 30, 2012</strong></p>
293
 
294
  <ul>
215
  <h1 id="shortcodes">E) Shortcodes - <a href="#toc">top</a></h1>
216
 
217
  <p>
218
+ There are two shortcodes available for use with this plugin.
219
+ </p>
220
 
221
+ <h2>A) members - <a href="#toc">top</a></h2>
222
+
223
+ <p>
224
  [members][/members] will hide the content within them unless the user is
225
  authenticated. Also works during searching, so that if a user searches for
226
  a term found in the shortcodes, but is not logged in, the page/post will
227
+ not show up in the results.
 
228
  </p>
229
 
230
+ <p>
231
+ <strong>role attribute</strong><br />
232
+ This shortcode also has an option to specify a specific role, using the following
233
+ syntax:
234
+ </p>
235
+
236
+ <pre>[members role="rolename"][/members]</pre>
237
+
238
+ <p>
239
+ If you want to specify a list of roles that are able to view the content, the syntax uses the or keyword:
240
+ </p>
241
+
242
+ <pre>[members role="or:author,contributor,editor"]</pre>
243
+
244
+ <p>
245
+ You can also specify a single role or multiple roles that cannot see it:
246
+ </p>
247
+
248
+ <pre>[members role="not:guest"]</pre>
249
+
250
+ <h2>A) nonmembers - <a href="#toc">top</a></h2>
251
+
252
  <p>
253
  [nonmembers][/nonmembers] will hide the content within them unless the user is
254
  not authenticated. Also works during searching, so that if a user searches for
314
 
315
  <h1 id="changelog">I) Changelog - <a href="#toc">top</a></h1>
316
 
317
+ <p><strong>Version 3.1.4 - August 30, 2012</strong></p>
318
+
319
+ <ul>
320
+ <li>Added not/or keywords to the role option of the members shortcode, syntax: [members role="not:guest,banned"][/members] and [members role="or:editor,author,contributor"] (Thanks to <a href="https://twitter.com/damphlett">Dave Amphlett</a> for the idea)</li>
321
+ </ul>
322
+
323
  <p><strong>Version 3.1.3 - August 30, 2012</strong></p>
324
 
325
  <ul>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: members, only, plugin, restricted, access, menus, 3.3, wp_nav_menu, nonmembers
5
  Requires at least: 2.9
6
  Tested up to: 3.3
7
- Stable tag: 3.1.3
8
 
9
  Restrict pages, posts, custom post types, menus and widgets to members, nonmembers or specific roles and still add to navigation
10
 
@@ -60,6 +60,10 @@ Yes, this is a new feature in 3.1.3. Use the syntax [members role="administrator
60
 
61
  == Changelog ==
62
 
 
 
 
 
63
  = 3.1.3 - August 30, 2012 =
64
 
65
  * Fixed a PHP warning about load_plugin_textdomain using a deprecated argument
4
  Tags: members, only, plugin, restricted, access, menus, 3.3, wp_nav_menu, nonmembers
5
  Requires at least: 2.9
6
  Tested up to: 3.3
7
+ Stable tag: 3.1.4
8
 
9
  Restrict pages, posts, custom post types, menus and widgets to members, nonmembers or specific roles and still add to navigation
10
 
60
 
61
  == Changelog ==
62
 
63
+ = 3.1.4 - August 30, 2012 =
64
+
65
+ * Added not/or keywords to the role option of the members shortcode, syntax: [members role="not:guest,banned"][/members] and [members role="or:editor,author,contributor"] (Thanks to Dave Amphlett for the idea)
66
+
67
  = 3.1.3 - August 30, 2012 =
68
 
69
  * Fixed a PHP warning about load_plugin_textdomain using a deprecated argument
wordpress-access-control.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://brandonwamboldt.ca/plugins/members-only-menu-plugin/
5
  * Author: Brandon Wamboldt
6
  * Author URI: http://brandonwamboldt.ca/
7
- * Version: 3.1.3
8
  * Description: This plugin is a powerful tool which gives you fine grained control over your pages and posts (and custom post types), allowing you to restrict a page, post, or custom post type to members, non-members, or even specific roles. You can customize how these pages and posts show up in search results, where users are directed when they visit them, and much more. <strong>You can even make your entire blog members only!</strong>.
9
  */
10
 
@@ -835,8 +835,35 @@ class WordPressAccessControl
835
 
836
  if ( is_user_logged_in() ) {
837
  if (isset($attributes['role'])) {
838
- if (!in_array($attributes['role'], $current_user->roles)) {
839
- return '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
840
  }
841
  }
842
 
4
  * Plugin URI: http://brandonwamboldt.ca/plugins/members-only-menu-plugin/
5
  * Author: Brandon Wamboldt
6
  * Author URI: http://brandonwamboldt.ca/
7
+ * Version: 3.1.4
8
  * Description: This plugin is a powerful tool which gives you fine grained control over your pages and posts (and custom post types), allowing you to restrict a page, post, or custom post type to members, non-members, or even specific roles. You can customize how these pages and posts show up in search results, where users are directed when they visit them, and much more. <strong>You can even make your entire blog members only!</strong>.
9
  */
10
 
835
 
836
  if ( is_user_logged_in() ) {
837
  if (isset($attributes['role'])) {
838
+
839
+ // Determine the syntax (Singular role, OR syntax or NOT syntax)
840
+ if (substr($attributes['role'], 0, 3) == 'or:') {
841
+ $roles = explode(',', substr($attributes['role'], 3));
842
+
843
+ $has_a_role = false;
844
+
845
+ foreach ($roles as $role) {
846
+ if (in_array($role, $current_user->roles)) {
847
+ $has_a_role = true;
848
+ break;
849
+ }
850
+ }
851
+
852
+ if (!$has_a_role) {
853
+ return '';
854
+ }
855
+ } else if (substr($attributes['role'], 0, 4) == 'not:') {
856
+ $roles = explode(',', substr($attributes['role'], 4));
857
+
858
+ foreach ($roles as $role) {
859
+ if (in_array($role, $current_user->roles)) {
860
+ return '';
861
+ }
862
+ }
863
+ } else {
864
+ if (!in_array($attributes['role'], $current_user->roles)) {
865
+ return '';
866
+ }
867
  }
868
  }
869