Advertisement
designbymerovingi

Limit View Content Hook to once per post

Feb 3rd, 2015
893
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. /**
  2.  * View Content Hook Adjustment
  3.  * Force the View Content hook to only award points once per post.
  4.  * @version 1.1.2
  5.  */
  6. add_filter( 'mycred_add', 'mycred_pro_view_once_per_post', 10, 3 );
  7. function mycred_pro_view_once_per_post( $reply, $request, $mycred ) {
  8.  
  9.     if ( ! in_array( $request['ref'], array( 'view_content', 'view_content_author' ) ) || $reply === false ) return $reply;
  10.  
  11.     extract( $request );
  12.  
  13.     if ( $mycred->has_entry( $ref, $ref_id, $user_id, $data, $type ) )
  14.         return false;
  15.  
  16.     return $reply;
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement