Skip to content

Bulk Restrict Custom Post Types #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions add-ons/pmpro-cpt/sql-bulk-restrict-cpt.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* The recipe will restrict CPTs for specific levels
* If you are using the Custom Post Type Membership Access Add On to restrict CPT access,
* this recipe will help you speed up the initial set up but
* replicating membership requirements across all CPTs of a selected post_type for a specific level.

* title: Restricting Custom Post Types
* layout: snippet
* collection: restricting-content
* category: restricting-content, CPTs, bulk update, sql
* link: https://www.paidmembershipspro.com/restrict-access-bulk-methods/
*
* This is a SQL query and should not be added to your theme or site as PHP code.
* Instead, you can run this query using a database management tool like phpMyAdmin
* or through your hosting control panel's database access (e.g. cPanel > phpMyAdmin).
* Always make a full database backup before running SQL queries on your live site.
*/

/** Example SQL to add restriction on CPT 'gallery' for Level ID 3.
Change CPT name and ID for your needs.*/
INSERT IGNORE INTO wp_pmpro_memberships_pages (membership_id, page_id)
SELECT '3', ID FROM wp_posts WHERE post_type = 'gallery';