• Resolved jwfoster2014

    (@jwfoster2014)


    Hi there…

    Firstly, love working with this plug … you’ve done a great job!

    BUT … need a bit of help 🙂

    I have a set of custom post types that I want to incorporate the voting into … and just these. That’s not the issue.

    When a user visits the site I want them to do the following:
    -Choose the post they like
    -Vote on that post
    -Be able to return in 24 hours and ONLY be able to vote on THAT post again

    I hope this makes sense … and do you think it’s possible?

    Best!
    Jeffrey

    https://wordpress.org/plugins/wp-postratings/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Lester Chan

    (@gamerz)

    1. Not sure if that has anything to do with the plugin
    2/3. You can set the cookie to expire after 24 hours so they can vote again.

    Thread Starter jwfoster2014

    (@jwfoster2014)

    How would I set the Cookies to expire in 24 hours?

    I don’t see this option in the pugin control panel

    Thread Starter jwfoster2014

    (@jwfoster2014)

    Would something like this work:

    add_action( 'init', 'my_setcookie' );
    function my_setcookie() {
       setcookie( 'my-name', 'my-value', time() + 86400, COOKIEPATH, COOKIE_DOMAIN );
    }
    Plugin Author Lester Chan

    (@gamerz)

    You have to modify the plugin code https://github.com/lesterchan/wp-postratings/blob/master/wp-postratings.php#L627 to do it. It is not in the control panel since the plugin is designed to be rated once only.

    Thread Starter jwfoster2014

    (@jwfoster2014)

    Lester …

    Thanks so much!

    I modified `// Only Create Cookie If User Choose Logging Method 1 Or 3
    $postratings_logging_method = intval(get_option(‘postratings_logging_method’));
    if($postratings_logging_method == 1 || $postratings_logging_method == 3) {
    $rate_cookie = setcookie(“rated_”.$post_id, $ratings_value[$rate-1], time() + 30000000, apply_filters(‘wp_postratings_cookiepath’, SITECOOKIEPATH));
    }`

    To look like this

    // Only Create Cookie If User Choose Logging Method 1 Or 3
    					$postratings_logging_method = intval(get_option('postratings_logging_method'));
    					if($postratings_logging_method == 1 || $postratings_logging_method == 3) {
    						$rate_cookie = setcookie("rated_".$post_id, $ratings_value[$rate-1], time() + 86400, apply_filters('wp_postratings_cookiepath', SITECOOKIEPATH));
    					}

    Fingers crossed 🙂

    Plugin Author Lester Chan

    (@gamerz)

    Yea just ensure you choose logged by Cookie in the Ratings Options =)

    Thread Starter jwfoster2014

    (@jwfoster2014)

    Yup, did just that!

    Thanks for the assist!! Greatly appreciated!

    Thread Starter jwfoster2014

    (@jwfoster2014)

    Another quick question …

    If I were to remove the .$post_id from the string would that limit the user to only ONE vote TOTAL per day, meaning they wouldn’t be able to vote on any other posts at all that day?

    Which is what I really want to happen 🙂

    Plugin Author Lester Chan

    (@gamerz)

    Yeap!

    Thread Starter jwfoster2014

    (@jwfoster2014)

    awesome 🙂

    Thread Starter jwfoster2014

    (@jwfoster2014)

    Still having an issue – SORRY!!

    Settings:
    Who Is Allowed To Rate? Guests Only
    Ratings Logging Method: Logged by Cookies

    The code in wp-postratings.php is set to

    // Only Create Cookie If User Choose Logging Method 1 Or 3
    					$postratings_logging_method = intval(get_option('postratings_logging_method'));
    					if($postratings_logging_method == 1 || $postratings_logging_method == 3) {
    						$rate_cookie = setcookie("rated_", $ratings_value[$rate-1], time() + 86400, apply_filters('wp_postratings_cookiepath', SITECOOKIEPATH));
    					}

    And I’m still able to go to other posts that have the ratings shortcode in them and vote 🙁 Am I overlooking something?

    Plugin Author Lester Chan

    (@gamerz)

    You might need to change https://github.com/lesterchan/wp-postratings/blob/master/wp-postratings.php#L295 to read the new cookie, forggoten about that.

    Thread Starter jwfoster2014

    (@jwfoster2014)

    SWEET!
    Great Catch!! That seems to be working! 🙂

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Only Allow One Vote’ is closed to new replies.