mycred_user_has_paid_for_content

Description

This filter allows you to indicate if the current user has paid / not paid for a particular content. Before a content is rendered that is set for sale using the Sell Content add-on, myCRED needs to determine if the current user has paid for the content or not. This in turn, determines if we should render the actual content or if we need to load a template asking the user to pay or buy more points (depending on your setup).

Available since version 1.4

Parameters

Param Type Required Description
$has_paid bool Yes

Either TRUE indicating the has paid and the content should be rendered or FALSE to force the user to pay to see the content.

$user_id int No

The numeric ID of the user that we are checking payment for.

$post_id int No

The post object ID that is set for sale.

$last_payment obj No

If the user has paid for the content (expired or not expired) this will contain the log entry pulled from the myCRED log. If no payment is found, this will return NULL. Added in 1.7.

Used By

Package Prio. Description
mycred/content 10 Used by the mycred_user_paid_for_content function.

Examples

Example 1: Allow Authors to see content set for sale using the Sell Content add-on without having to pay.

Example 2: Allow users that has reached a specific myCRED Rank to view content that has been set for sale. Requires myCRED 1.7+