EDD Restricted content. Present excerpt instead of content

Marko Krstić
27 May 2022

This can be placed in Oxygen code block or you can make it as short-code. It will display excerpt if user is not logged in or didn’t purchased specific product.

Replace XXXXX with your product ID on line 9

<?php

// If user IS NOT logged in or DOES NOT have ACF Add on
if(!is_user_logged_in()){
	the_excerpt();
} else {
    // If user IS logged in AND DOES have SPECIFIC PRODUCTS	
	global $current_user;
	if( edd_has_user_purchased($current_user->ID, XXXXX) ) {
		the_content();	
	} else {
		// If user IS logged in AND DOES not have ACF Add on
		the_excerpt();
	}
}
?>

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy