The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#11
|
||||
|
||||
You're extremely helpful. Thank you again.
I did get it working. I did have one more question however. If I am specifying a lot of different usergroups in my template and plugin and don't want to have to individually go back and change each template anytime I make a change in my usergroups, is there a way I can define an array in place of the usergroups? Something like: <vb:if condition="in_array($GLOBAL['forumid'], $MyUsergroups)"> ? How would I create a plugin that would then feed $MyUsergroups to the templates? Thank you again. |
#12
|
|||
|
|||
What you could do in that case is set a variable in the plugin to true, then in the template condition just check the variable. In fact you could use the $show[] array that exists already, as long as you choose a name that you're sure would be unique.
For example, in the plugin you could do something like: Code:
$MyUsergroups = array(1, 3, 5, 57); if (is_member_of($bbuserinfo, $MyUsergroups)) { ...some code.. $show['some_unique_name'] = true; ... more code } Code:
<vb:if condition="$show['some_unique_name']"> // show something </vb:if> |
#13
|
||||
|
||||
My Plugin Code:
Code:
//This plugin controls users accepting the rules on each post until they are promoted to Registered Users Plus. //Template edits for this plugin have been made in SHOWTHREAD, NEWREPLY, and NEWTHREAD //A custom phrase called spelling_checkbox was added $SpellingUsergroups = array(2, 3, 4, 6); if (is_member_of($vbulletin->userinfo, $SpellingUsergroups)) { $show['spelling_checker'] = true; $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>"; } } Code:
<vb:if condition="$show['spelling_checker']"> <div class="spelling_checkbox"> <ul class="checkradio"> <li><label for="rules"> <input type="checkbox" id="rules" class="bginput" name="accept_rules" value="true"/> {vb:rawphrase spelling_checkbox} </label></li> </ul> </div> </vb:if> Am I making a mistake by putting the $SpellingUsergroups = array(2, 3, 4, 6); and $show['spelling_checker'] = true; in the same plugin as the other code? Does it need to be in a different plugin at a different hook location? Right now all of this is at newpost_process... --------------- Added [DATE]1352047913[/DATE] at [TIME]1352047913[/TIME] --------------- Ok I added a new plugin, using this example of yours: Code:
$MyUsergroups = array(1, 3, 5, 57); if (is_member_of($bbuserinfo, $MyUsergroups)) { ...some code.. $show['some_unique_name'] = true; ... more code } |
#14
|
|||
|
|||
You say the plugin is using newpost_process but your template change is in SHOWTHREAD? That's probably the problem because newpost_process isn't called before SHOWTHREAD.
|
#15
|
||||
|
||||
Thanks again.
I have 2 plugins now and then 3 template edits (in showthread, newreply, and newthread) My first plugin which is called at parsetemplates: Code:
$SpellingUsergroups = array(6, 7); if (is_member_of($vbulletin->userinfo, $SpellingUsergroups)) { $show['spelling_checker'] = true; } My second plugin which is called at newpost_process Code:
//This plugin controls users accepting the rules on each post until they are promoted to Registered Users Plus. //Template edits for this plugin have been made in SHOWTHREAD, NEWREPLY, and NEWTHREAD //A custom phrase called spelling_checkbox was added if (is_member_of($vbulletin->userinfo, $SpellingUsergroups)) { $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>"; } } And my template edit: Code:
<vb:if condition="$show['spelling_checker']"> <div class="spelling_checkbox"> <ul class="checkradio"> <li><label for="rules"> <input type="checkbox" id="rules" class="bginput" name="accept_rules" value="true"/> {vb:rawphrase spelling_checkbox} </label></li> </ul> </div> </vb:if> Now the plugin that works at parse_templates is working properly. It will show the template edits to the proper usergroup and the checkbox shows up. However if I see the checkbox and try to make a post without clicking on the checkbox, it still allows it...making me think the plugin at newpost_process is not correctly getting the $SpellingUsergroups definition that is being defined in the plugin at parsetemplates. Thanks for sticking with me through this -- I am learning quite a bit but am still hitting a few speed bumps. Thank you. |
#16
|
|||
|
|||
Yeah, I think the problem is that the newpost_process hook is being called before parse_templates. If that's all the code you have in your parse_templates plugin, try moving it to global_setup_complete (or whatever it's called - I can never remember).
|
#17
|
||||
|
||||
Tried it at global_setup_complete and global_bootstrap_init_start and neither seem to work.
|
#18
|
|||
|
|||
Oh yeah...try it again, but add "global $vbulletin, $show;" at the beginning.
|
#19
|
||||
|
||||
Ok it still allows me to post without having the checkbox selected.
Here's how I have it now: Code:
global $vbulletin, $show; $SpellingUsergroups = array(6, 67); if (is_member_of($vbulletin->userinfo, $SpellingUsergroups)) { $show['spelling_checker'] = true; } |
#20
|
|||
|
|||
OK, try changing the newpost_process plugin to:
Code:
global $show; if ($show['spelling_checker']) { |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|