How Can We Help?

Template Functions for Pay For Post with WooCommerce

You are here:
← All Topics

Out of the box this plugin will work with any theme which uses the standard WordPress function the_content() for those themes that do not utilize the_content() you can use the following static functions in your templates.

Woocommerce_Pay_Per_Post_Helper::has_access()

This checks if the current user has access to the page. It returns true/false

Woocommerce_Pay_Per_Post_Helper::get_no_access_content()

This returns the content specified in the PPP Options.

And example of this working together would be something like the following:

 

<?php if(Woocommerce_Pay_Per_Post_Helper::has_access()): ?>
    This is the content that a user should see if they paid for the post
<?php else: ?>
    <?php echo Woocommerce_Pay_Per_Post_Helper::get_no_access_content(); ?>
<?php endif; ?>