<?php
// Custom lock
// Get current user if it is not already present
if ( !$user ) {
$user = wp_get_current_user();
}
// Check how much patronage the user has
$user_patronage = Patreon_Wordpress::getUserPatronage();
// Default the vip status
$vip = 'no';
$vip = get_user_meta( $user->ID, 'cb_p6_a1_vip_user', true );
$user_patreon_level = get_user_meta( $user->ID, 'cb_p6_a1_patreon_level', true );
// Set where we want to have the user land at - this can be anything. The below code sets it to this exact page. This page may be a category page, search page, a custom page url with custom parameters - anything
$redir = home_url(add_query_arg($_GET,$wp->request));
// If the user has less patronage than, say, $7, and is not an admin-level user or a vip user, lock the post.
if ( ( $user_patronage < 700 )
AND !current_user_can( 'manage_options' )
) {
if ( $vip != 'yes' AND ( $user_patreon_level AND $user_patreon_level < 700 ) ) {
// Generate the unlock interface wherever it is
echo Patreon_Frontend::displayPatreonCampaignBanner(
7,
array( 'direct_unlock' => 7,
'redirect' => $redir
)
);
// the first param (7) and direct_unlock param set the unlock value for this interface. Both need to be provided and be the same
}
}
else {
?>
}
?>