Advertisement
designbymerovingi

Daily Video View Points

Oct 3rd, 2017
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. /**
  2.  * Allow Daily Video Points
  3.  * Allow users to gain points for watching the same video every 24 hours
  4.  * @version 1.0
  5.  */
  6. function mycred_pro_daily_video_view( $has_entry, $reference, $ref_id, $user_id, $data, $type ) {
  7.  
  8.     if ( $reference == 'watching_video' ) {
  9.  
  10.         global $wpdb, $mycred;
  11.  
  12.         $check = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$mycred->log_table} WHERE user_id = %d AND ref = %s AND data = %s AND ctype = %s AND time > %d;", $user_id, $reference, $data, $type, ( current_time( 'timestamp' ) - DAY_IN_SECONDS ) ) );
  13.         if ( $check === NULL )
  14.             return false;
  15.  
  16.         return true;
  17.  
  18.     }
  19.  
  20. }
  21. add_filter( 'mycred_has_entry', 'mycred_pro_daily_video_view', 10, 6 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement