Skip to content

Instantly share code, notes, and snippets.

@michaelbeil
Forked from ideadude/pmpro-cpt.php
Last active June 19, 2023 22:44
Show Gist options
  • Save michaelbeil/844c50437b8a93064c0ab92ef4db69d7 to your computer and use it in GitHub Desktop.
Save michaelbeil/844c50437b8a93064c0ab92ef4db69d7 to your computer and use it in GitHub Desktop.
Add the PMPro meta box to a CPT. Add this to your plugin/etc.
<?php
/**
* Add the PMPro meta box to a CPT
*
* 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_pmpro_meta_box_to_cpts() {
// Duplicate this row for each CPT. This one adds the meta boxes to 'advert' CPTs.
add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'advert', 'side' );
}
add_action( 'admin_menu', 'my_add_pmpro_meta_box_to_cpts', 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment