MyBB Community Forums

Full Version: How to prevent users from taking a poll?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Right now at my forum i allow people to link their steam profile to mybb
currently i'm able to block user who does not have steam linked from posting/replying/quick edit
but i donno how to prevent user's without steam linked to be able to take a poll 


So the question is there anyway to prevent users from taking a poll using plugins?  Big Grin Big Grin
You have 2 options imho.

1. Create a group for those who add steam links which has poll permissions.
2. Add a plugin.

Quote:So the question is there anyway to prevent users from taking a poll using plugins?

Should be easy to write. Have you any experience with MyBB plugins or at least basic PHP?
(2017-12-02, 07:59 PM)labrocca Wrote: [ -> ]You have 2 options imho.

1. Create a group for those who add steam links which has poll permissions.
2. Add a plugin.

Quote:So the question is there anyway to prevent users from taking a poll using plugins?

Should be easy to write. Have you any experience with MyBB plugins or at least basic PHP?

Some.... No expert I there any hooks or anything? Would ppreciated for pointing me in the right direction
Hook into "polls_vote_start" and do a check for your $mybb->user parameter then throw and error message if it isn't set.

It's a good starter plugin to make. Go for it.
(2017-12-02, 09:08 PM)labrocca Wrote: [ -> ]Hook into "polls_vote_start" and do a check for your $mybb->user parameter then throw and error message if it isn't set.  

It's a good starter plugin to make. Go for it.

thx

here is what i have and works

$plugins->add_hook("polls_vote_start", "prevent_poll");

function prevent_poll()

{
redirect($mybb->settings['bburl'] . '/usercp.php?action=steam_link', 'vote prevented');
}

now my question is i have game coloumn added to the mybb_forums 
$db->add_column('forums', 'game', 'TEXT DEFAULT NULL');

how do i get the game field for the specific forum?

i tried 
global $forum;
var_dump($forum['game'];

but always get null
Try to add $fid to your global. Then use the forum cache instead of an sql query.
(2017-12-03, 07:09 AM)labrocca Wrote: [ -> ]Try to add $fid to your global.  Then use the forum cache instead of an sql query.

thank you very much i've got it working  Big Grin

heres the pseudo code for any newbie like me  Big Grin

$plugins->add_hook("polls_vote_start", "hook_poll");

function hook_poll()
{

global $fid;
var_dump($fid); //gets forum id currently in
$forum_cache = cache_forums();
var_dump($forum_cache[$fid]['column_you_want_here']); //get the data of column you want from the mybb_forum table
}
Great. Glad you see with MyBB creating simple plugins really is simple to do.