Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'transition_post_status', 'mycredpro_all_content_for_sale', 99, 3 );
- function mycredpro_all_content_for_sale( $new_status, $old_status, $post ) {
- // Make sure this is only applied to "Posts" and no other point type
- if ( ! isset( $post->post_type ) || $post->post_type != 'post' ) return;
- // Make sure the post is transitioning from not being published to being published e.g. Draft > Publish
- if ( $new_status !== 'publish' || $old_status === 'publish' ) return;
- // Get price
- $price = get_post_meta( $post->ID, 'ndna-price', true);
- // Set post for sale
- $setup = array(
- 'status' => 'enabled', // enabled - for sale, disabled - not for sale
- 'price' => $price, // price in points
- 'button_label' => 'Get access to this lead', // the purchase button label
- 'expire' => 0 // Option to expire sale after x number of days
- );
- // Save to enable
- update_post_meta( $post->ID, 'myCRED_sell_content', $setup );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement