Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SQL Query to copy parent post restrictions to their children for Paid Memberships Pro
# 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
You can’t perform that action at this time.