{"id":21937015,"url":"https://github.com/WebDevStudios/content-restriction-for-wordpress","last_synced_at":"2025-10-09T19:31:26.739Z","repository":{"id":261285115,"uuid":"883840083","full_name":"robertdevore/content-restriction-for-wordpress","owner":"robertdevore","description":"Enables role-based content restriction by post type, taxonomy term, or individual post/page, redirecting unauthorized users to login when needed.","archived":false,"fork":false,"pushed_at":"2024-12-22T06:46:49.000Z","size":167,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-22T07:27:59.802Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertdevore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-05T17:00:30.000Z","updated_at":"2024-12-18T01:29:24.000Z","dependencies_parsed_at":"2024-11-05T18:36:01.615Z","dependency_job_id":"dd9e2784-8a36-43b0-ac3e-b46575ac0c06","html_url":"https://github.com/robertdevore/content-restriction-for-wordpress","commit_stats":null,"previous_names":["robertdevore/content-restriction-for-wordpress"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdevore%2Fcontent-restriction-for-wordpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdevore%2Fcontent-restriction-for-wordpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdevore%2Fcontent-restriction-for-wordpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdevore%2Fcontent-restriction-for-wordpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertdevore","download_url":"https://codeload.github.com/robertdevore/content-restriction-for-wordpress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235854919,"owners_count":19055685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T01:17:22.355Z","updated_at":"2025-10-09T19:31:21.376Z","avatar_url":"https://github.com/robertdevore.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Content Restriction for WordPress®\n\nEnables role-based content restriction by post type, taxonomy term, or individual post/page, redirecting unauthorized users to login when needed.\n\n## Description\n\n**Content Restriction for WordPress®** allows administrators to restrict access to content based on user roles. \n\nYou can set restrictions globally for post types and taxonomy terms or individually for posts and pages. Unauthorized users will be redirected to the login page or see a customizable message if they try to access restricted content.\n\n## Features\n\n- **Restrict by Post Type or Taxonomy Term**: Globally restrict content based on post types and taxonomy terms.\n- **Individual Post/Page Restrictions**: Restrict specific posts or pages with custom role requirements.\n- **Role-Based Access Control**: Set minimum user roles required to view content.\n- **Automatic Redirection**: Redirect unauthorized users to the login page.\n- **Customizable Messages**: Display custom messages for restricted content.\n- **REST API and RSS Feed Integration**: Content restrictions are respected in REST API responses and RSS feeds.\n\n## Installation\n\n1. **Download the Plugin**: Clone or download the plugin from the [GitHub repository](https://github.com/robertdevore/content-restriction-for-wordpress/).\n\n2. **Upload to WordPress®**:\n\n    - Navigate to **Plugins** \u003e **Add New** in your WordPress® admin dashboard.\n    - Click on **Upload Plugin** and select the downloaded ZIP file.\n    - Click **Install Now** and then **Activate** the plugin.\n3. **Via FTP** (Alternative):\n\n    - Upload the plugin folder to the `/wp-content/plugins/` directory.\n    - Activate the plugin through the **Plugins** menu in WordPress®.\n\n## Usage\n\n### Global Content Restrictions\n\n1. **Access Settings**:\n\n    - Go to **Settings** \u003e **Content Restriction** in the WordPress® admin dashboard.\n2. **Add a Restriction**:\n\n    - Click on the **Add Restriction** button.\n3. **Configure Restriction**:\n\n    - **Restrict content by**: Select a **Post Type** or **Taxonomy Term** to restrict.\n    - **Role**: Choose the minimum user role required to access the content.\n4. **Save Changes**:\n\n    - Click the **Save Changes** button to apply the restrictions.\n\n### Individual Content Restrictions\n\n1. **Edit Post/Page**:\n\n    - Open the post or page you want to restrict in the editor.\n2. **Restrict Content Metabox**:\n\n    - In the **Restrict Content** metabox (usually located in the sidebar), check **Restrict this content**.\n3. **Select Minimum Role**:\n\n    - Choose the minimum user role required from the dropdown menu.\n4. **Update Post/Page**:\n\n    - Click **Update** or **Publish** to save your changes.\n\n### Behavior for Unauthorized Users\n\n- **Logged-Out Users**:\n    - Redirected to the login page when accessing restricted content.\n- **Logged-In Users Without Required Role**:\n    - See a message: \"This content is restricted. Please log in to view it.\"\n\n## Filters and Actions\n\n### Customizing Restriction Messages\n\nYou can customize the restriction messages using filters in your theme's `functions.php` file or a custom plugin.\n\n- **Content Message**:\n    ```\n    add_filter( 'crwp_restricted_content_message', function( $message ) {\n        return '\u003cp\u003eYou must be a premium member to view this content.\u003c/p\u003e';\n    } );\n    ```\n\n- **REST API Message**:\n    ```\n    add_filter( 'crwp_restricted_rest_message', function( $message ) {\n        return '\u003cp\u003eRestricted content. Please upgrade your membership.\u003c/p\u003e';\n    } );\n    ```\n\n- **RSS Feed Message**:\n    ```\n    add_filter( 'crwp_restricted_feed_message', function( $message ) {\n        return '\u003cp\u003eContent is restricted in the feed. Visit the site to view.\u003c/p\u003e';\n    } );\n    ```\n\n### Available Filters\n\nThe plugin provides several filters that allow developers to customize its behavior. Below are details for each filter, including usage examples.\n\n#### `crwp_restricted_content_message`\n\n**Description**:  \nFilters the message displayed to unauthorized users when they attempt to access restricted content on the front end.\n\n**Parameters**:\n\n- `$message` _(string)_: The default restriction message.\n\n**Usage**:\n\nAdd the following code to your theme's `functions.php` file or a custom plugin to modify the restricted content message:\n```\n/**\n * Customize the restricted content message displayed to unauthorized users.\n *\n * @param  string $message The default restriction message.\n * @return string The customized restriction message.\n */\nfunction my_custom_restricted_content_message( $message ) {\n    return '\u003cp\u003eYou must be a premium member to view this content.\u003c/p\u003e';\n}\nadd_filter( 'crwp_restricted_content_message', 'my_custom_restricted_content_message' );\n```\n\n**Returns**:\n\n- _(string)_: The customized message to display to unauthorized users.\n\n#### `crwp_restricted_rest_message`\n\n**Description**:  \nFilters the message returned in REST API responses for restricted content. This ensures that any applications or services consuming your REST API will receive a consistent message for restricted content.\n\n**Parameters**:\n\n- `$message` _(string)_: The default REST API restriction message.\n\n**Usage**:\n\nTo modify the message returned in REST API responses for restricted content, add the following code:\n```\n/**\n * Customize the REST API restricted content message.\n *\n * @param  string $message The default REST API restriction message.\n * @return string The customized restriction message.\n */\nfunction my_custom_restricted_rest_message( $message ) {\n    return '\u003cp\u003eContent is restricted via the REST API. Please log in.\u003c/p\u003e';\n}\nadd_filter( 'crwp_restricted_rest_message', 'my_custom_restricted_rest_message' );\n```\n\n**Returns**:\n\n- _(string)_: The customized message to return in REST API responses for restricted content.\n\n#### `crwp_restricted_feed_message`\n\n**Description**:  \nFilters the message displayed in RSS feeds for restricted content. This is useful if you want to prevent unauthorized users from accessing restricted content through RSS readers.\n\n**Parameters**:\n\n- `$message` _(string)_: The default feed restriction message.\n\n**Usage**:\n\nCustomize the RSS feed message by adding the following code:\n```\n/**\n * Customize the RSS feed restricted content message.\n *\n * @param  string $message The default feed restriction message.\n * @return string The customized restriction message.\n */\nfunction my_custom_restricted_feed_message( $message ) {\n    return '\u003cp\u003eThis content is restricted in the feed. Visit the website to access it.\u003c/p\u003e';\n}\nadd_filter( 'crwp_restricted_feed_message', 'my_custom_restricted_feed_message' );\n```\n\n**Returns**:\n\n- _(string)_: The customized message to display in RSS feeds for restricted content.\n\n### Notes\n\n- These filters should be added to your theme's `functions.php` file or within a custom plugin.\n- Remember to replace the messages in the examples with your desired custom messages.\n- Double check that any HTML used in the messages is properly sanitized and valid.\n\n## Frequently Asked Questions\n\n### Does this plugin support custom post types and taxonomies?\n\nYes, it supports all public custom post types and taxonomies registered in WordPress®.\n\n### Can I restrict content to multiple user roles?\n\nYou can set the minimum required role for content access. Users with that role or higher will have access.\n\n### What happens to restricted content in the REST API and RSS feeds?\n\nRestricted content will display a restriction message instead of the actual content.\n\n## Screenshots\n\n1. **Content Restriction Settings Page**\n\n2. **Restrict Content Metabox**\n\n## Contributing\n\nContributions are welcome! Please open issues and submit pull requests on the [GitHub repository](https://github.com/robertdevore/content-restriction-for-wordpress/).\n\n## License\n\nThis plugin is licensed under the [GPL-2.0+ License](http://www.gnu.org/licenses/gpl-2.0.txt).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebDevStudios%2Fcontent-restriction-for-wordpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWebDevStudios%2Fcontent-restriction-for-wordpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebDevStudios%2Fcontent-restriction-for-wordpress/lists"}