Skip to content

Instantly share code, notes, and snippets.

@kimcoleman
Last active October 26, 2023 08:40
Show Gist options
  • Save kimcoleman/19265deeb657228b4922eb6bccee38f9 to your computer and use it in GitHub Desktop.
Save kimcoleman/19265deeb657228b4922eb6bccee38f9 to your computer and use it in GitHub Desktop.
Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder.
<?php
/**
* Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder:
* https://wordpress.org/plugins/elementor/
*
* Your administrator-level account must have a Membership Level in order to edit all of the pages assigned
* under Memberships > Pages.
*
* You must also set a Custom Field on the Membership Checkout page with the key 'pmpro_default_level' and
* value of a level ID in order to properly edit your Membership Checkout page using Elementor.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function elementor_compatibility_for_pmpro() {
if ( defined('PMPRO_VERSION') ) {
// Remove the default the_content filter added to membership level descriptions and confirmation messages in PMPro.
remove_filter( 'the_content', 'pmpro_level_description' );
remove_filter( 'pmpro_level_description', 'pmpro_pmpro_level_description' );
remove_filter( 'the_content', 'pmpro_confirmation_message' );
remove_filter( 'pmpro_confirmation_message', 'pmpro_pmpro_confirmation_message' );
// Filter members-only content later so that the builder's filters run before PMPro.
remove_filter('the_content', 'pmpro_membership_content_filter', 5);
add_filter('the_content', 'pmpro_membership_content_filter', 15);
}
}
add_action( 'init', 'elementor_compatibility_for_pmpro' );
@physiostasis
Copy link

How do you set a custom field on the membership check out page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment