phpBB User vote event - get voter ID

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
aster59
Registered User
Posts: 82
Joined: Sun Jun 26, 2016 1:47 pm
Location: United States

phpBB User vote event - get voter ID

Post by aster59 »

I need to get the user identifiers for people who cast votes onto a poll for my extension. It looks like there is a database table that records the info called phpbb_poll_votes, I can see user IDs and IP! I can't get it in any PHP events however. I tried core.viewtopic_modify_poll_data. I tried a bunch of the $event parameter array options but it isn't spitting it out.
https://wiki.phpbb.com/Event_List#core. ... _poll_data

I guess I could query the DB in the event function, but thought $event had what I needed. Any ideas?

Thanks.
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: phpBB User vote event - get voter ID

Post by javiexin »

What do you want to do with polls?
Take a look at the Advanced Polls extension, and you may find what you are looking for. And if the functionality is not there, and is general enough, let me know, and I might include it...
In any case, you may take a look at the code to see where to get such information. It is in the event, for sure, but you have to be very careful: sometimes is in the topic data, and sometimes is in the poll data. It is quite a complex extension though I must say, and the code is not as clean as I would like it to be.
Link: viewtopic.php?f=456&t=2326116

Note it is for 3.1 only at this point, due to the use of custom notifications. I will port it to 3.2, just don't know when (as I want to do a major rewrite of it as well). If you can live without poll notifications :), you can try the extension in 3.2, and should work just fine. Let me know, and I will tell you how to remove notifications for 3.2.
-javiexin
aster59
Registered User
Posts: 82
Joined: Sun Jun 26, 2016 1:47 pm
Location: United States

Re: phpBB User vote event - get voter ID

Post by aster59 »

javiexin wrote:
Sat Apr 29, 2017 8:49 pm
What do you want to do with polls?
Take a look at the Advanced Polls extension, and you may find what you are looking for. And if the functionality is not there, and is general enough, let me know, and I might include it...
In any case, you may take a look at the code to see where to get such information. It is in the event, for sure, but you have to be very careful: sometimes is in the topic data, and sometimes is in the poll data. It is quite a complex extension though I must say, and the code is not as clean as I would like it to be.
Link: viewtopic.php?f=456&t=2326116

Note it is for 3.1 only at this point, due to the use of custom notifications. I will port it to 3.2, just don't know when (as I want to do a major rewrite of it as well). If you can live without poll notifications :), you can try the extension in 3.2, and should work just fine. Let me know, and I will tell you how to remove notifications for 3.2.
-javiexin
It is pretty specific to the extension I am working on! I need users to get virtual currency for voting and have the points deposit into a column created by my extension in the users table.

The only issue I am having, which event if you know?
https://wiki.phpbb.com/Event_List#core. ... _poll_data
That fires off when the user visits a post with a poll. This is not good. I only want it to fire if they vote.

I would need like a core.submit_post_end event, not viewtopic.php - although I might be able to make it work.
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: phpBB User vote event - get voter ID

Post by javiexin »

core.viewtopic_modify_poll_data
Use voted_id array to see votes in the submitted form.
Post Reply

Return to “Extension Writers Discussion”