Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanve/access
WP plugin to control user access via taxonomy terms
https://github.com/ryanve/access
role-based-access-control role-manager roles wordpress wordpress-plugin wp-plugin
Last synced: about 1 month ago
JSON representation
WP plugin to control user access via taxonomy terms
- Host: GitHub
- URL: https://github.com/ryanve/access
- Owner: ryanve
- Created: 2013-07-01T04:04:45.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-09-21T22:20:37.000Z (about 4 years ago)
- Last Synced: 2024-05-02T00:08:31.214Z (7 months ago)
- Topics: role-based-access-control, role-manager, roles, wordpress, wordpress-plugin, wp-plugin
- Language: PHP
- Size: 11.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [Access](../../)
#### Access is a simple scalable WordPress plugin to control user access via the [taxonomy API](http://codex.wordpress.org/Taxonomies) and user [roles/capabilities](http://codex.wordpress.org/Roles_and_Capabilities)/IDs.
## Usage
Create access terms via Posts → Access → Add New. Choose any name and set its slug to a [role](http://codex.wordpress.org/Roles_and_Capabilities#Roles), [capability](http://codex.wordpress.org/Roles_and_Capabilities#Capabilities), or user ID.
#### Example Terms
Name
Slug
Restricts By
Members
read
capability
Editors
editor
role
John Doe
47
user ID
Access terms can be added to any post type via Edit (or Quick Edit) similar to how categories are added. Posts with access terms are only seen by users logged in with sufficient capability. Denied posts are excluded from the loop.
## UX
### Contexts
- Viewing an access-controlled singular item. (Its [permalink](http://en.wikipedia.org/wiki/Permalink).)
- Viewing a collection that includes (all or some) access-controlled items. In this case only items that the current user has permission to view are displayed.### Customization
Use a hook to display a [login form](http://codex.wordpress.org/Function_Reference/wp_login_form) and/or message to inform users that they can log in to access more content.
#### Hooks
##### Filter hooks during the `'loop_start'` action
- `'@access:message'` runs for all cases
- `'@access:message:!denied'` runs if all posts are not denied
- `'@access:message:!limited'` runs if posts are all granted or all denied
- `'@access:message:!granted'` runs if all posts are not granted
- `'@access:message:denied'` runs if all posts are denied
- `'@access:message:limited'` runs if some posts are granted, some denied
- `'@access:message:granted'` runs if all posts are granted##### Example Message
```php
add_filter('@access:message', function($message, $grants, $denies) {
if (is_user_logged_in()) return;
$url = admin_url();
return "Login to view additional content.";
}, 10, 3);
```##### Example Login Form
```php
add_filter('@access:message', function($message, $grants, $denies) {
if (is_user_logged_in()) return;
$form = "Login
" . wp_login_form(array('echo' => 0));
return "$form";
}, 10, 3);
```#### CSS
For CSS purposes, messages are wrapped in a `div.access-message` with an applicable contextual class.
## Install
Requires: PHP 5.3+
1. Upload to the `/wp-content/plugins/` directory
1. Activate through the Plugins menu in WordPress## Fund
Fund development with [tips to @ryanve](https://www.gittip.com/ryanve/) =)
## License: [MIT](http://opensource.org/licenses/MIT)
Copyright (C) 2013 by [Ryan Van Etten](https://github.com/ryanve)