Advertisement
designbymerovingi

#00000424-1

Aug 30th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. $post_id = get_the_ID();
  2. $user_id = get_current_user_id();
  3. if ( ! is_user_logged_in() ) {
  4.  
  5.     // Viewed by visitor
  6.  
  7. }
  8. elseif ( function_exists( 'mycred_count_ref_id_instances' ) && mycred_count_ref_id_instances( 'buy_content', $post_id, $user_id ) ) {
  9.  
  10.     // User has paid, show link
  11.  
  12. }
  13.  
  14. // Using myCRED 1.7+
  15. elseif ( function_exists( 'mycred_sell_content_payment_buttons' ) ) {
  16.  
  17.     global $mycred_modules, $mycred_sell_this;
  18.  
  19.     $post             = get_post( $post_id );
  20.     $payment_options  = mycred_sell_content_payment_buttons( $user_id, $post_id );
  21.  
  22.     // Triggers the sales script in the footer of the website.
  23.     $mycred_sell_this = true;
  24.  
  25.     // Can afford to buy
  26.     if ( $payment_options !== false ) {
  27.  
  28.         // The template saved in your settings. You could also just set a html template here and now
  29.         // If you decide to write a custom template here, make sure you include the %buy_button% template tag.
  30.         $content = $mycred_modules['solo']['content']->sell_content['templates']['members'];
  31.  
  32.         $content = str_replace( '%buy_button%', $payment_options, $content );
  33.  
  34.         // Renders the needed html wrapping around your template
  35.         $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-unpaid' );
  36.  
  37.     }
  38.  
  39.     // Can not afford to buy
  40.     else {
  41.  
  42.         // The template saved in your settings. You could also just set a html template here and now
  43.         $content = $mycred_modules['solo']['content']->sell_content['templates']['cantafford'];
  44.  
  45.         // Renders the needed html wrapping around your template
  46.         $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-insufficient' );
  47.  
  48.     }
  49.  
  50.     echo $content;
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement