Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-26-2011, 01:05 PM
tastyratz tastyratz is offline
 
Join Date: Nov 2008
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Way to force "I agree" checkbox before posting in specific forums?

Hello,
We are having issues with user compliance with rules of "forgetting" them.

I would like to force a checkbox for our marketplace section where users have to agree they are an interested party only.

I want this ONLY in the marketplace forum, and I want it persistent against all posts in the section.

Is there a plugin/hack out there which could cleanly fit my needs on a 3.8 install?
Reply With Quote
  #2  
Old 04-26-2011, 02:59 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not sure what you mean by "persistent against all posts" - do you mean you just want them to answer once, or each time they post?

If it's the first one I don't know, maybe there's a mod out there. If it's the second one, you could create a plugin using hook newpost_process and something like this code:

Code:
if (in_array($foruminfo['forumid'], array(1, 2, 3)))
{
   $vbulletin->input->clean_gpc('p', 'accept_rules', TYPE_BOOL);

   if (!$vbulletin->GPC['accept_rules'])
   {
       $errors[] = "You must accept the rules before posting";
   }
}

then in the appropriate templets (showthread, newreply, and newthread I think), add something like this:

Code:
<if condition="in_array($foruminfo['forumid'], array(1, 2, 3))">
<tr>
   <td><input type="checkbox" class="bginput" name="accept_rules" value="true"/> I accept the forum rules</td>
</tr>
</if>

(You don't have to make it a table row of course.)

You also want to change the 1, 2, 3 in each case to the forum number or numbers you want this to apply to.

You could also make a javascript popup to check before it's submitted if you like that idea better.
Reply With Quote
  #3  
Old 11-03-2012, 08:34 AM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Would this work on vB4?
Reply With Quote
  #4  
Old 11-03-2012, 09:25 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think it should, but you'd have to update the "if" tags in the template like this:

Code:
<vb:if condition="in_array($foruminfo['forumid'], array(1, 2, 3))">
<tr>
   <td><input type="checkbox" class="bginput" name="accept_rules" value="true"/> I accept the forum rules</td>
</tr>
</vb:if>
Reply With Quote
Благодарность от:
RedTurtle
  #5  
Old 11-03-2012, 08:15 PM
CoffeeLovesYou CoffeeLovesYou is offline
 
Join Date: Feb 2010
Posts: 176
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

kh99,

We have a forum that has cursing in it and can have serious conversations.. How can I use your plugin to make it so when they click on the forum, it gives them the same checkbox, and if they press I agree, it shows them the forum and all of the threads/posts and what not. Kind of like how if you go to a certain website, it may say "Content not suitable for children".. well, I want it to be kind of like a warning "This area of the forum has language that may not be suitable for children and serious conversations. Leave now and go back to the main forum if not interested. Agree if you'd like to proceed into the forum." something like that.

Thank you!
Reply With Quote
  #6  
Old 11-03-2012, 10:12 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's more complicated. It's fairly easy to do for posting because there's already a mechanism for checking for errors and going to the "go advanced" page if there are any, and it's a one-time thing. To do what you want you'd have to create your own way to decide if the user had accepted or not (because you don't want them to have to click for every page). You should spend some time searching for something like this if you haven't already. If you want to create it, you might look at how forum passwords work because it's a similar idea. Or maybe you can figure out a way to use the forum password mechanism, like make the password "agree" then change the forum password message to say "if you accept enter 'agree'".
Reply With Quote
  #7  
Old 11-04-2012, 12:06 AM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I think it should, but you'd have to update the "if" tags in the template like this:

Code:
<vb:if condition="in_array($foruminfo['forumid'], array(1, 2, 3))">
<tr>
   <td><input type="checkbox" class="bginput" name="accept_rules" value="true"/> I accept the forum rules</td>
</tr>
</vb:if>
Thanks again for being so helpful kh99

I have created and enabled the plugin as you suggested above and am now putting the following in my SHOWTHREAD template, right above the code for the signature checkbox:

Code:
<vb:if condition="in_array($foruminfo['forumid'], array(3, 4, 17, 24))">
<tr>
   <td><input type="checkbox" class="bginput" name="accept_rules" value="true"/>I agree to follow the rules.</td>
</tr>
</vb:if>
I checked that both the plugin and this template code have the same forum IDs in the code but for some reason it doesn't appear on the SHOWTHREAD page.

Any idea what I could be doing wrong? Thank you!
Reply With Quote
  #8  
Old 11-04-2012, 12:59 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're using vb4, right? (Edit: of course, you just mentioned it above). Try this instead (change foruminfo to threadinfo):

Code:
<vb:if condition="in_array($threadinfo['forumid'], array(3, 4, 17, 24))">
<tr>
   <td><input type="checkbox" class="bginput" name="accept_rules" value="true"/>I agree to follow the rules.</td>
</tr>
</vb:if>
Reply With Quote
  #9  
Old 11-04-2012, 01:03 AM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Kh99,

So I am having an issue with the plugin.

I'm using the following code:

Code:
if ($GLOBALS['forumid'] != 99 AND is_member_of($bbuserinfo, 5,6,7))
{
   $vbulletin->input->clean_gpc('p', 'accept_rules', TYPE_BOOL);

   if (!$vbulletin->GPC['accept_rules'])
   {
       $errors[] = "<span style='color: #ba0000; background-color: #FDFD65;'>Please scroll down and accept the highlighted rules before submitting your post.</span>";
   }
}
Because I want it to show in all forums (put the 99 in there to make it work) and I want it to only apply to usergroups 5,6,7 (admin, mod, super mod).

Now if I use is_member_of($bbuserinfo, 5,6,7) it doesn't seem to work. If I put an exclamation in front of it then it works...but I'm not sure why...

EDIT: So here's the following things I've tried, as an admin:

if ($GLOBALS['forumid'] !=99 AND is_member_of($bbuserinfo, 5,6,7)) <== Doesn't work (lets me post)
if ($GLOBALS['forumid'] !=99 AND is_member_of($bbuserinfo, 2,3,4)) <== Works (lets me post)
if ($GLOBALS['forumid'] !=99 AND !is_member_of($bbuserinfo, 5,6,7)) <=== Doesn't let me as an admin post (so it works, but not sure why it needs an ! in front of is_member_of)
Reply With Quote
  #10  
Old 11-04-2012, 09:02 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can only use $bbuserinfo in a template condition. If you want to check in a plugin, use $vbulletin->userinfo. Also, if you want it to work for all forums you can just take out the forum check (unless you're leaving it there for future use or something). So try:
Code:
if (is_member_of($vbulletin->userinfo, 5,6,7))
{

I guess in the other thread I assumed when you asked for a conditional you meant a template condition.

BTW, ! just means "not", so it was working only because the check was always failing (so !is_member_of was always true), but I think you would have found that it was true for all members.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:00 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05003 seconds
  • Memory Usage 2,267KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (8)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete