Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Maximum Content Purchases
- * Enforces a maximum number times a post can be purchased.
- * @version 1.0
- */
- function mycred_pro_limit_content_purchases( $buttons, $user_id, $post_id ) {
- if ( $buttons === false ) return $buttons;
- global $mycred_sold_out;
- $maximum_sales = 5;
- $count = mycred_count_ref_id_instances( 'buy_content', $post_id, NULL, MYCRED_DEFAULT_TYPE_KEY );
- // If we reached our limit, pretend the user can not afford to pay for this content
- if ( $count >= $maximum_sales ) {
- $mycred_sold_out = true;
- return false;
- }
- return $buttons;
- }
- add_filter( 'mycred_sellcontent_buttons', 'mycred_pro_limit_content_purchases', 10, 3 );
- /**
- * Sold Out Template
- * @version 1.0
- */
- function mycred_pro_show_sold_out_template( $template ) {
- global $mycred_sold_out;
- if ( $mycred_sold_out === true )
- return '<p>This content has sold out.</p>';
- return $template;
- }
- add_filter( 'mycred_sell_content_template', 'mycred_pro_show_sold_out_template' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement