Created
July 15, 2021 18:30
-
-
Save ideadude/0166ef9082f76493559776278ee7edc6 to your computer and use it in GitHub Desktop.
Add "select all" option inside the PMPro Require Membership box
This file contains hidden or 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
<?php | |
/** | |
* Add "select all" option inside the Require Membership box | |
* 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 my_add_select_all_levels() { | |
?> | |
<script> | |
jQuery(document).ready(function() { | |
var my_sal_toggle = true; | |
jQuery('#membershipschecklist').before('<a href="javascript:void();" id="my_pmpro_select_all_levels">select all</a>'); | |
jQuery('#my_pmpro_select_all_levels').click(function(){ | |
jQuery('#membershipschecklist input').prop('checked', my_sal_toggle); | |
my_sal_toggle = ! my_sal_toggle; | |
}); | |
}); | |
</script> | |
<?php | |
} | |
add_action( 'pmpro_after_require_membership_metabox', 'my_add_select_all_levels' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment