Skip to content

Instantly share code, notes, and snippets.

@zaacwilliam1
Last active November 20, 2020 10:15
Show Gist options
  • Save zaacwilliam1/53dc8a003c460243850d7daac346ce2a to your computer and use it in GitHub Desktop.
Save zaacwilliam1/53dc8a003c460243850d7daac346ce2a to your computer and use it in GitHub Desktop.
<?php
add_action( 'template_redirect', 'view-content' );
function view-content{
if ( is_singular( 'post' ) ) {
//your code here...
if(is_user_logged_in() && function_exists('pmpro_hasMembershipLevel') && pmpro_hasMembershipLevel())
{
global $current_user;
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
$level = $current_user->membership_level->name;
if( $level == 1 ){
//hook set-up for Level 1 membership_level
mycred_add( 'viewing_content', $user_id, 10, 'Points for post viewd level one' );
}
A
if($level == 2 ){
//hook for Level 2
mycred_add( 'viewing_content', $user_id, 20, 'Points for post views level two' );
}
if($level == 3 ){
//hook for Level 2
mycred_add( 'viewing_content', $user_id, 30, 'Points for post views level three' );
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment