• Resolved MathiasP

    (@mathiasp)


    Heyho,

    is it possible to substract more points from a user via wordpoints_subtract_points than he had earned in the points_type?

    I count all Points from users together (also with other plugins) and want to substract some points for “gifts”.

    I Created a new Points hook (named: substract) where it should be possible to substract as many Points as I want (even if the Points will be negative)

    Is it possible to realize something like that? Actually it is just possible to substract the points the user has earned in one Point hook (point type)

    Thx and greez!

    https://wordpress.org/plugins/wordpoints/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author J.D. Grimes

    (@jdgrimes)

    Hello Mathias,

    Yes, it is possible for a user to have negative points. However, by default WordPoints enforces a minimum of 0 points. You can change the minimum using the wordpoints_points_minimum filter.

    Plugin Author J.D. Grimes

    (@jdgrimes)

    P.S. — Thank you for the review. 🙂

    Thread Starter MathiasP

    (@mathiasp)

    Hey, review for a good plugin 🙂

    one more question:

    I tried to implement the minimum filter but it doesn’t work the way I need it

    Here is my code:

    function user_stats_set_minimum_points($minimum, $type){
        if ( 'substract' === $type ) {
            $minimum = 5000;
        }
        return $minimum;
    }
    add_filter('wordpoints_points_minimum','user_stats_set_minimum_points',10,2);

    If I now substract points with

    wordpoints_subtract_points($user_id, 200, 'substract', 'training_event_winner');

    the log shows (+) 5000 Points for the user in substract points type.

    What I need is: If I use wordpoints_substract_points in the Points type substract (let’s say 200) just substract the points even if the user has 0 Points in that points type

    p.s.: I dont even need a limit just substract some points if need to.

    is it possible with this filter?

    I hope you unterstand my question 🙂

    Plugin Author J.D. Grimes

    (@jdgrimes)

    I think it is actually working correctly. If you set the minimum to 5000, a user cannot have less than 5000 points. I think you want to set it to -5000 instead. 😉 I know that you don’t need a limit, but it doesn’t have a way to remove the limit completely. You can work around it by using a very large negative number as the minimum.

    Thread Starter MathiasP

    (@mathiasp)

    Uh yeah the – did it 😉 thx

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘substract more poits than earned in one point hook’ is closed to new replies.