Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Customize Sell Content Price
- * Set a custom price for post content based on post type or
- * taxonomy relationships.
- * @mycred
- * @version 1.0
- */
- add_filter( 'mycred_get_content_price', 'mycred_pro_content_price_by_type', 10, 4 );
- function mycred_pro_content_price_by_type( $price, $post_id, $point_type, $user_id ) {
- $post_type = get_post_type( $post_id );
- // Pages always cost 5 points
- if ( $post_type == 'page' )
- return 5;
- // Posts in the category "premium plus" costs 10 while all other posts cost 15
- if ( $post_type == 'post' ) {
- $terms = wp_get_object_terms( $post_id, 'category', array( 'fields' => 'slugs' ) );
- if ( ! empty( $terms ) && in_array( 'premium-plus', $terms ) )
- return 10;
- return 15;
- }
- // Returns default
- return $price;
- }
Add Comment
Please, Sign In to add comment