• Resolved monitor

    (@oomskaap)


    Hello Gabriel,

    I am busy creating a “profile page”. Basically my goal is to echo specific point awards individually. Daily points, Comment points, etc.
    So far it looks like this:

    https://i.imgur.com/IulQ7ks.png

    As you can see, i already echo the total points via
    <?php echo do_shortcode('[mycred_my_balance]'); ?>

    Now, I would like to echo only “Daily (logged in)” points. In the log I can see that it classifies it as “xxx points for for logging in”

    Is there some code that I can use for example:
    <?php echo do_shortcode('[mycred_loggedinpoints]'); ?> ?

    Secondly, I would like to echo only “Comment” points.
    In the log i can see it classifies it as “xxx points for Approved Comment”

    Is there some code that I can use for example:
    <?php echo do_shortcode('[mycred_commentpoints]'); ?> ?

    Lastly, i would like to echo “number of Points used”, in the log file i see it indicates it as “purchases”.

    I hope you can see what I am trying to do, as this would be quite a nice looking profile. You may have some other future point classifications can will appear in the log. It would be nice if each one can be echo’ed individually.

    I will wait and see if you have a solution for this, and then apply it to my profile. Thanks a lot!

    https://www.ads-software.com/extend/plugins/mycred/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author myCred

    (@designbymerovingi)

    Each time users are awarded / deducted points for example via a hook, there is a custom reference used. So you could query the Database for all entries for today that has i.e. ‘logging_in’ which is used when a user gets points for logging in. You will find it under the ‘ref’ column in the log db. Timestamp is under ‘time’.

    If you are comfortable with PHP and SQL there is the has_entry() method in the abstract class myCRED_Hook. (mycred/abstracts/mycred-abstract-hook.php) It is an example of how mycred checks log entries in the database. It would be a starting point.

    On the other hand if you are not into PHP I would see if I could help you write something.

    Thread Starter monitor

    (@oomskaap)

    Unfortunately I don’t know much about PHP or SQL.

    Whenever you have some time, I would appreciate if you can write the template tags for me. Again, it’s no rush.

    Thanks.

    Plugin Author myCred

    (@designbymerovingi)

    I have created a function that lets you get the total credits awarded / deducted from midnight till now for a specific reference.

    Example: Show total amount of points given today for logins for all users:

    echo mycred_todays_entries( 'logging_in' );

    Example: As above but for the current user

    echo mycred_todays_entries( 'logging_in', get_current_user_id() );

    Function:
    https://pastebin.com/d7ETmDtL

    Thread Starter monitor

    (@oomskaap)

    Thanks, I have tested it and it works. I will use this on the site.

    Just one question. I intent to echo the total logging_in points that a user has accumulated. If each login gets him 10 points, and he have logged in 5 times, i want to echo “50” as the accumulated amount.

    Your code, would basically just echo “10” each day since the time span is just 1 day and not adding each time, right?

    echo mycred_todays_entries( 'logging_in' ); works nice. Is there a way to include all all points given, including comments and other. It would be nice to show it on the homepage as “Today we have given out xxx of points”

    Thanks again for that code, i’ll use that echo on our site.

    Plugin Author myCred

    (@designbymerovingi)

    Yes, as the name suggests it is only showing points for today but you could build on this and adjust it to your needs. If you are looking to keep track of several days you could for example add to the function that it saves it in a new value per day that you then fetch in order. There are many options.

    Right now the above function requires you to enter a reference but I made an alternative below that just counts everything for the same time period.

    https://pastebin.com/W8UiWcrD

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Echo individual point statistics?’ is closed to new replies.