Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'mycred_add', 'daily_link_click_limit', 10, 3 );
- function daily_link_click_limit( $reply, $request, $mycred )
- {
- if ( $request['ref'] != 'link_click' || $reply === false ) return $reply;
- $max_per_day = 25;
- $user_id = absint( $request['user_id'] );
- global $wpdb;
- $count = $wpdb->get_var( $wpdb->prepare( "
- SELECT COUNT( * )
- FROM {$mycred->log_table}
- WHERE ref = %s
- AND user_id = %d
- AND time > %d;", 'link_click', $user_id, date_i18n( 'U', strtotime( 'today midnight' ) ) ) );
- if ( $count >= $max_per_day )
- return false;
- return $reply;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement