Find Answers and Get Support › Forums › Cera – Intranet & Community Theme › Website Setup › Posts › How to use Membership Pro to create PayWall?
- This topic has 2 replies, 3 voices, and was last updated 3 years, 10 months ago by Themosaurusrex.
-
AuthorPosts
-
MuamerParticipant@mllapan
- 13 Topics
- 33 Posts
Well, I need something to acomplish with this theme, but I noticed in the content-single, it uses this function:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php /** * Functions hooked into cera_single action * * @hooked cera_single - 10 * @hooked cera_grimlock_single - 10 */ do_action( 'cera_single' ); ?> </article><!-- #post-## -->
With previous theme I used to put paywall with this function:
/* Prikazaće određeni broj riječi u postu, a zatim ispod obavijest da je tekst samo za VIP korisnike. */ function vip_part_text( $atts, $content = null ) { if(is_user_logged_in()){ $content = apply_filters('the_content', get_the_content()); echo $content; } else { $more = ' <br> ... <br> <div class="advert" style=""> <div class="advert-page" style=""> <a style="" href="https://mllapan.com/pretplata/" target="_blank"> <div class="pretplata">Nemate dozvolu da pročitate ovaj članak u potpunosti. <br> Kupite doživotni VIP pristup svim člancima na stranici. <br> Uz VIP dobijate 24/7 pomoć na forumu također. <br> Za više informacija kliknite ovdje. <br> </a> </div> </div> '; $content = apply_filters('the_content', get_the_content()); echo force_balance_tags( html_entity_decode( wp_trim_words( htmlentities( $content ), 100, $more ) ) ); } }
With this inside functions.php, I just called the shortcode in single-custom-template.php:
<?php echo do_shortcode('[vip_part_text]'); ?>
Now that I am using membership pro with this theme, I found that easiest way to limit text would be to combine this code:
<?php if(pmpro_hasMembershipLevel(array('12','14','Gold'))) { ?> //Place your HTML or PHP code here if the user is in the required membership level ... <?php } ?>
But I am not sure how to implement it on
do_action( 'cera_single' );
, I mean, I would like to show particular number of words in the post and under that would be an URL that would lead user to buy membership pro in case he is not a membership pro user, if he is, he would be able to see full text.So, can you help me to sort this out?
October 2, 2020 at 14:37 #23834@themodactyl- 0 Topics
- 6587 Posts
Hi @mllapan,
Thanks for getting in touch! We’ve received your request and we’ll get you an answer shortly. 🙂
We’re experiencing a much larger number of requests than usual so our wait times are longer than expected. We’re working hard to get back to you as quickly as we can and we really appreciate your patience!
We really thank you for your patience!
In the meantime, feel free to check out our documentation resources for more help:
Kind regards,
October 3, 2020 at 09:07 #23858@themosaurusrex- 0 Topics
- 2048 Posts
Hi @mllapan,
You can achieve this by using the
cera_single
action, simply hook your function to this action. Please also make sure to remove the functions already hooked to this action if (and only if) necessary. For more about WordPress actions and hooks, please read the following post:
https://www.wpbeginner.com/glossary/action/If you wish to custom code to your site, we recommend that you use the Code Snippets plugin (https://wordpress.org/plugins/code-snippets/). If you have never activated this plugin, please read the following post:
Please also note that we don’t provide any theme customization. So, you shouldn’t expect other snippets from us unless it’s to fix an issue stemming from our own codebase. We always try our best to help theme users whenever we can and only provide code snippets out of courtesy to prevent them from waiting for the next update.
Regards,
October 5, 2020 at 11:08 #23904 -
AuthorPosts
Hi there,
This topic has been inactive for a while now so we will be closing it to keep the forum tidy. Don't hesitate to create a new topic if you still need help and we'll be glad to help you!
Best regards,
The Themosaurus team.
The topic ‘How to use Membership Pro to create PayWall?’ is closed to new replies.