strangerstudios / pmpro-series

This is the "drip feed content" module for Paid Memberships Pro.
https://www.paidmembershipspro.com/add-ons/pmpro-series-for-drip-feed-content/
25 stars 25 forks source link

Custom post types #23

Closed agrolsy closed 4 years ago

agrolsy commented 10 years ago

Is it possible to add support for custom post types? Instead of just being able to select posts and pages f ex being able to select a WP Courseware course unit? (without having to create a post/page that shows just that unit)

dryan1144 commented 10 years ago

I was able to accomplish this by modifying line 413 of class.pmproseries.php:

$pmpros_post_types = apply_filters("pmpros_post_types", array("post", "page", "your_cpt_here"));

but of course this is not update-proof. Not sure how to make it more dynamic.

agrolsy commented 10 years ago

Thanks a million for your super fast response and solution!! That worked very well! I'll just watch out for future updates and hope that a setting for which post types to include can be shown in the future.

adaptifyDesigns commented 9 years ago

Since it looks like the $pmpros_post_types value is wrapped in a filter hook (the pmpros_post_types filter), is there a way to update this variable via a child theme's functions.php file?

I'm not certain how one would write the filter function though... I tried referencing the WP docs about it here, but I don't feel confident enough to mess around with writing my own filter, and I'm still not even sure the plugin has been written to allow us to filter that post type array in the $pmpros_post_types variable.

Any suggestions from the developers?

mdriess commented 9 years ago

I also need a solution for this.

positivejam commented 9 years ago

To anyone who might come across this thread: you can add PMPro Series support for your custom post types by putting the following code in your functions.php file:

function add_cpt_to_pmpro_series($postTypes) {
  // Repeat the following line for other post types as necessary
  $postTypes[] = 'yourPostTypeHere';
  return $postTypes;
}
add_filter('pmpros_post_types', 'add_cpt_to_pmpro_series');

Just replace yourPostTypeHere with the name of your custom post type. This will keep any existing post types available, but also tack on the one you specify.

dparker1005 commented 4 years ago

Closing as this question has been answered by @positivejam.