Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * View Content Hook Adjustment
- * Limit points to be awarded once per day per unique post.
- * @version 1.0.2
- */
- add_filter( 'mycred_add', 'mycred_pro_view_once_per_post', 10, 3 );
- function mycred_pro_view_once_per_post( $reply, $request, $mycred ) {
- if ( ! in_array( $request['ref'], array( 'view_content', 'completing_quiz_full' ) ) || $reply === false ) return $reply;
- if ( $request['ref'] == 'view_content' ) {
- $post_id = absint( $request['ref_id'] );
- $post_categories = wp_get_post_categories( $post_id );
- if ( in_array( 89, (array) $post_categories ) || in_array( 90, (array) $post_categories ) )
- return false;
- }
- global $wpdb;
- $until = current_time( 'timestamp' );
- $check = $wpdb->get_row( $wpdb->prepare( "
- SELECT *
- FROM {$mycred->log_table}
- WHERE ref IN ( 'view_content', 'completing_quiz_full' )
- AND user_id = %d
- AND ref_id = %d
- AND time BETWEEN %d AND %d;", $request['user_id'], $request['ref_id'], mktime( 0, 0, 0, date( 'n', $until ), date( 'j', $until ), date( 'Y', $until ) ), $until ) );
- if ( isset( $check->ref_id ) )
- return false;
- return $reply;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement