Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $post_id = get_the_ID();
- $user_id = get_current_user_id();
- if ( ! is_user_logged_in() ) {
- // Viewed by visitor
- }
- elseif ( function_exists( 'mycred_count_ref_id_instances' ) && mycred_count_ref_id_instances( 'buy_content', $post_id, $user_id ) ) {
- // User has paid, show link
- }
- // Using myCRED 1.7+
- elseif ( function_exists( 'mycred_sell_content_payment_buttons' ) ) {
- global $mycred_modules, $mycred_sell_this;
- $post = get_post( $post_id );
- $payment_options = mycred_sell_content_payment_buttons( $user_id, $post_id );
- // Triggers the sales script in the footer of the website.
- $mycred_sell_this = true;
- // Can afford to buy
- if ( $payment_options !== false ) {
- // The template saved in your settings. You could also just set a html template here and now
- // If you decide to write a custom template here, make sure you include the %buy_button% template tag.
- $content = $mycred_modules['solo']['content']->sell_content['templates']['members'];
- $content = str_replace( '%buy_button%', $payment_options, $content );
- // Renders the needed html wrapping around your template
- $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-unpaid' );
- }
- // Can not afford to buy
- else {
- // The template saved in your settings. You could also just set a html template here and now
- $content = $mycred_modules['solo']['content']->sell_content['templates']['cantafford'];
- // Renders the needed html wrapping around your template
- $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-insufficient' );
- }
- echo $content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement