Last active
March 29, 2021 02:59
-
-
Save ideadude/7fc2153f05d38167dc2c9ba1f7df6879 to your computer and use it in GitHub Desktop.
SQL Query to copy parent post restrictions to their children for Paid Memberships Pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy page restrictions from parent pages to child pages. | |
# NOTE that this doesn't delete any existing restrictions for the child pages. | |
INSERT IGNORE INTO wp_pmpro_memberships_pages (membership_id, page_id) | |
SELECT mp.membership_id, p.ID | |
FROM wp_posts p | |
LEFT JOIN wp_pmpro_memberships_pages mp ON p.post_parent = mp.page_id | |
WHERE mp.membership_id IS NOT NULL | |
AND p.post_type IN ( 'page' ) | |
AND p.post_parent <> p.ID; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Bulk methods to restrict access to posts, pages, and CPTs for a specific membership level ID via MySQL" at Paid Memberships Pro here: https://www.paidmembershipspro.com/bulk-methods-to-restrict-access-to-posts-pages-and-cpts-for-a-specific-membership-level-id-via-mysql/