Hi @tgilber007,
Thank you for contacting us, we have forwarded the details to the technical team we will get back to you once we heard back from them.
Hi @tgilber007,
This is working now, Also, the YouTube subscription code, It’s very old code, It doesn’t work now.
add_shortcode( 'water_consumption', 'mycredpro_click_for_points' );
function mycredpro_click_for_points( $atts, $content = '' ) {
extract( shortcode_atts( array(
'ref' => '',
'message' => '',
'hours' => 2,
'points' => 10
), $atts ) );
$last_entry = false;
// Must be logged in to see this shortcode
if ( ! is_user_logged_in() ) return;
// Get current time
$now = current_time( 'timestamp' );
$user_id = get_current_user_id();
// Get last entry
$log = new myCRED_Query_Log( array(
'user_id' => $user_id,
'ref' => $ref,
'number' => 1
) );
if ( $log->have_entries() )
$last_entry = $log->results[0];
// Intercept button clicks
if ( isset( $_GET['water-intake'] ) && isset( $_GET['token'] ) && wp_verify_nonce( $_GET['token'], 'new-water-intake' ) ) {
// User clicked on button, award points
if( !$last_entry || ( $last_entry && (int)$last_entry->time + ( $hours * HOUR_IN_SECONDS ) <= $now ) )
{
mycred_add(
$ref,
$user_id,
$points,
'Report of water intake'
);
}
// Show users a message showing they got points or something
return '<p>' . $message . '</p>';
}
// User has an entry
if ( $log->have_entries() ) {
// Make sure enough time has passed by removing x hours from the current time
if ( (int)$last_entry->time + ( $hours * HOUR_IN_SECONDS ) <= $now ) {
// Show the user the button they need to click on
return '<a href="' . add_query_arg( array(
'water-intake' => $now,
'token' => wp_create_nonce( 'new-water-intake' )
) ) . '" class="btn btn-primary">Click to report water intake</a>';
}
}
else
{
// Show the user the button they need to click on
return '<a href="' . add_query_arg( array(
'water-intake' => $now,
'token' => wp_create_nonce( 'new-water-intake' )
) ) . '" class="btn btn-primary">Click to report water intake</a>';
}
// Else just show somethig for users
return '<p>' . $content . '</p>';
}
Thank you the code is working well
1.another how to disable the video after it watched by the user
2. Allow users to gain points for watching the same video every 24 hours https://pastebin.com/h9wdkZpX This code is not work for me
I tried this one also its not work https://mycred.me/support/forums/topic/seem-to-have-lost-video-watching-points/
add_action( 'mycred_has_entry', 'mycred_pro_unlimited_video_points', 10, 6 );
function mycred_pro_unlimited_video_points( $has_entry, $reference, $ref_id, $user_id, $data, $type ) {
if ( $reference == 'watching_video' )
return false;
return $has_entry;
}
-
This reply was modified 4 years, 3 months ago by
tgilber007.
@tgilber007,
Our QA Team is looking into it will get back to you soon.
@tgilber007,
This code is working perfectly fine Daily Video View Points – Pastebin.com , Make sure you used this code in current theme’s functions.php file.
And hook should be enabled Points for viewing Videos.