WordPress.org

Ready to get started?Download WordPress

Forums

myCRED
[resolved] Set daily action and point limits (3 posts)

  1. Heather Acton
    Member
    Posted 5 months ago #

    Hi there,
    I need to implement an overall daily points limit and an overall daily actions limit that applies to all users. After a user hits that daily limit they'd still have their action logged, but they'd just receive 0 points.

    I know that I need to edit the mycred_add filter, but can't seem to get the full function figured out. Any help is greatly appreciated.

    Thank you!
    Heather

    https://wordpress.org/plugins/mycred/

  2. Gabriel
    Member
    Plugin Author

    Posted 5 months ago #

    Hi Heather.

    Technically, what you are looking for is possible to do, but there are a couple of "speed bumps" to watch out for.

    1. myCRED it self will not allow log entries with zero points. This is because a lot of limitations in myCRED like maximum number of times you can do something each day are all based on your log entries. This means that we will need to update the database and add entries without using any of the myCRED provided functions.

    2. You will need to keep an eye on limits you are enforcing since you are adding zero valued log entries. You might find some issue down. Just a heads up.

    Now regarding the code.
    You are correct in that we can use the mycred_add filter for this. But since we are not going to be able to use the add_to_log function we will need to populate the log our selves.

    If you are comfortable with PHP, the mycred-functions.php file is the file that handles log entries and could serve you as a start off point. Have a look at around line 1011 where the add_to_log function begins. You could use this code yourself but remove the zero balance check.

    Then it all comes down to checking if the user is over or under your daily limit and add entries into the log.

    Let me know if you want some code examples.

  3. Heather Acton
    Member
    Posted 5 months ago #

    Thanks so much, Gabriel - that will get me rolling. Much appreciated!

Reply

You must log in to post.

About this Plugin

About this Topic