Advertisement
designbymerovingi

myCRED Sell Content Settings

Mar 16th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. /**
  2. * array(
  3. * 'status' => 'enabled',
  4. * 'price' => 10,
  5. * 'button_label' => 'Buy Post',
  6. * 'expire' => true
  7. * )
  8. */
  9. $post_id = 1;
  10.  
  11. // Set a post for sale that has never been set for sale
  12. add_post_meta( $post_id, 'myCRED_sell_content', array(
  13. 'status' => 'enabled',
  14. 'price' => 10,
  15. 'button_label' => 'Buy This',
  16. 'expire' => false
  17. ), true );
  18.  
  19. // Re-enable the sale of a post that has been disabled
  20. $prefs = get_post_meta( $post_id, 'myCRED_sell_content', true );
  21. $prefs['status'] = 'enabled';
  22. update_post_meta( $post_id, 'myCRED_sell_content', $prefs );
  23.  
  24. // Disable sale of a post that is set to be for sale
  25. $prefs = get_post_meta( $post_id, 'myCRED_sell_content', true );
  26. $prefs['status'] = 'disabled';
  27. update_post_meta( $post_id, 'myCRED_sell_content', $prefs );
  28.  
  29. /**
  30. * If posts are set for sale and must remain for sale but you
  31. * want to disable it for a particular user without re-saving
  32. * the settings, you can use the mycred_is_content_for_sale filter.
  33. * Returns false will pretend the content is not for sale.
  34. */
  35. if ( get_current_user_id() === 123 )
  36. add_filter( 'mycred_is_content_for_sale', '__return_false' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement