Setup new capability for bridge conditions.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 27 Oct 2016 14:35:41 +0000 (10:35 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 27 Oct 2016 14:35:41 +0000 (10:35 -0400)
Limit a subscriber with this capability to only see Conditions in the
glmAssociate menu.

css/subscriberAdmin.css [new file with mode: 0644]
setup/adminMenus.php
setup/permissions.php
setup/rolesAndCapabilities.php

diff --git a/css/subscriberAdmin.css b/css/subscriberAdmin.css
new file mode 100644 (file)
index 0000000..fb912d5
--- /dev/null
@@ -0,0 +1,6 @@
+#toplevel_page_glm-members-admin-menu-members li.wp-first-item + li,
+#toplevel_page_glm-members-admin-menu-members li.wp-first-item + li + li
+{
+    display: none;
+}
+
index d0594e4..20084eb 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
-/**********************************************************************
- *  NOTE: THIS IS A CONDITIONS FILE - DO NOT USE UNMODIFIED
- *
- *  Please change all references to conditions, Conditions, or CONDITIONS to a name
- *  appropriate for your new Add-On.
- *
- *  This file is used to add main menus or sub-menus to the admin
- *  area. If this add-on does not create additional menus, this file
- *  should be omitted.
- *
- *  If adding a main menu, use "add_menu_page()" WordPress function
- *  instead and note any differences.
- *
- *  The menu slug should be constructed as
- *      "glm-members-admin-{page}-{action}"
- *  The default action for a page is usually "index".
- *
- *  Remove this message before using this file in production!
- **********************************************************************/
-
 /*
  * Added menus or sub-menus examples
  *
@@ -92,3 +72,9 @@ add_submenu_page(
     function() {$this->controller('conditions');}
 );
 
+$user = wp_get_current_user();
+if ( in_array( 'subscriber', (array) $user->roles ) ) {
+    if ( current_user_can( 'glm_members_edit_conditions' ) ) {
+        wp_enqueue_style('glmConditionsSubscriberAdminStyle', GLM_MEMBERS_CONDITIONS_PLUGIN_URL . 'css/subscriberAdmin.css' );
+    }
+}
index 461451a..cdf68b8 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
-
-/**********************************************************************
- *  NOTE: THIS IS A CONDITIONS FILE - DO NOT USE UNMODIFIED
- *
- *  Please change all references to conditions, Conditions, or CONDITIONS to a name
- *  appropriate for your new Add-On.
- *
- *  This file is used to add permission checks that can be used throught
- *  the main plugin and add-ons. If no such permissions are needed by
- *  this add-on, this file should be omitted.
- *
- *  Remove this message before using this file in production!
- **********************************************************************/
-
 /*
  * Below are permission checks for various specific things in this add-on and
  * elsewhere in the Member DB main plugin and add-ons.
index 5285546..5ec28ac 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
-/**********************************************************************
- *  NOTE: THIS IS A CONDITIONS FILE - DO NOT USE UNMODIFIED
- *
- *  Please change all references to conditions, Conditions, or CONDITIONS to a name
- *  appropriate for your new Add-On.
- *
- *  This file is used to add roles and capability. If none are required,
- *  this file should be omitted.
- *
- *  Remove this message before using this file in production!
- **********************************************************************/
-
 /**
  * NOTE: This file is only included in the activate.php process.
  *       It is not regularly used during operation.
  */
+
+$roles = get_editable_roles();
+foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) {
+    if (isset($roles[$key]) && $role->has_cap('edit_posts')) {
+        $role->add_cap('glm_members_edit_conditions');
+    }
+}