• Resolved elliesatt

    (@zee300)


    Hi there

    Thanks so much for creating this plugin – such a necessity for any forum! I am trying to integrate this with Gamipress (a gamification plugin) so that users are awarded points (a) when they upvote something, and (b) when their topic/reply is upvoted.

    Events can be passed to Gamipress via a ‘custom event’ trigger (tutorial and example here: https://gamipress.com/snippets/tutorials/creating-a-custom-event/).

    Looking at the hook that you list on your FAQ, am I right in saying that I won’t be able write something to award points to the user whose topic/reply is being upvoted – just the user that is upvoting the topic/reply?

    I am completely new to writing PHP hooks etc so I would really, really appreciate any guidance or code examples you can hook me up with. Thanks very much in advance!

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

    (@natekinkead)

    This is very doable. Using my bbp_voting_voted hook, you will have the $post_id. With that, you can get the author of that post with this…
    $author_id = get_post_field ('post_author', $post_id);

    Thread Starter elliesatt

    (@zee300)

    Hi Nate

    Thanks – I got this implemented and it seems to trigger nicely!

    • Ideally it should just trigger when upvoting occurs, not when downvoting. Do I still use the same hook, or do you hopefully have an ‘upvoted’ hook?
    • Also, right now if I upvote, downvote and upvote again, I trigger the event 3 times. It should be just the one time (i.e. the first upvote) for any individual topic or reply. Is this possible?
    Plugin Author natekinkead

    (@natekinkead)

    If you look at my FAQs, it shows that this hook gives you the direction of the vote…

    add_action( 'bbp_voting_voted', 'my_function_on_bbp_vote', 10, 4 );
    function my_function_on_bbp_vote( $post_id, $direction, $score, $identifier ) {
        // Do something
        // $post_id will be the ID of the topic or reply that was voted on
        // $direction will be 1 for upvote, -1 for downvote, or 0 for removed vote
        // $score will be the new total score
        // $identifier will be either a numeric user ID or an IP address of a non-logged-in visitor
    }
    Thread Starter elliesatt

    (@zee300)

    Thanks – all working!

    Plugin Author natekinkead

    (@natekinkead)

    You’re welcome!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Integration with Gamipress’ is closed to new replies.