$15 Paypal. Apply link_click restrictions to individual links.

front page Forums How-to Questions $15 Paypal. Apply link_click restrictions to individual links.

This topic contains 3 replies, has 2 voices, and was last updated by Avatar Explodingmule2 1 year, 11 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #33135

    So I want to restrict the amount of points users can get from individual urls each day e.g. 1 point for clicking this link, another point for clicking that link, no more points for clicking them again. I want it so the user can get points from clicking these same links each day. So 1 point per link/per day. I currently have this code in functions.php the thing is $max_per_day = 1; restricts link_click as a whole, so I would get 1 point for clicking 1 link with the hook enabled but not for any other links with link_click. It does however allow users to gain points from the same link each day, which I need.

    I guess you would need to search the ‘data’ table for URL’s and count them. Or perhaps when link_click url is clicked, save the url to a new column in mycred_log table and count from there.

    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 = 1;
    	$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;

    I’m willing to pay $15 via paypal


    Quite simple.

    Just contact me via my Contact Developer contact form. (I know… so much repetition, right ? 😀 )

    Cordially, M.


    Sounds good, I sent you a PM



Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.