This function checks if a given user has a valid and active payment for a specific post that is set for sale.

This function also checks if a purchase has expired. For this reason it can not be used to check if a user has made any payment for this content, only if that payment exists and has not yet expired (if used).

This function is only available if the Sell Content add-on is enabled.

Available since version 1.7


(bool) TRUE if the user has paid and the purchase has not expired else FALSE.


Param Type Required Description
function mycred_user_paid_for_content(
$user_id int Yes

The users numeric ID.

$post_id int Yes

The post objects ID.

) { ... }


Example 1: Check if the current post is set for sale and if it is, if the current user has paid for it.

global $post;

$user_id = get_current_user_id();
if ( mycred_post_is_for_sale( $post ) && mycred_user_paid_for_content( $user_id, $post->ID ) ) {

	// Post is for sale and the user has paid