vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=191666

[How-to] Add a multiselect field in vBulletin options
by Coroner
23 Sep 2008 14:03

I wrote this article 'cause I didn't found anything else but it was needed for mod I wrote.

Before I start - will have to say this is an example for a forumchooser.

In our product under options, create an option like this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I'll use: multiselect:eval.

Ok, we finished our first part and need 2 new plugins.

The first plugin we used is admin_options_print.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

See the code above and take a look at this three lines:
$array = construct_forum_chooser_options (0);
$selected = explode (',', $setting['value']);
$name .= "[]";
The 1st line are our options array, filled with information coming from the function "construct_forum_chooser_options(0)". If you wanna have your own, create an array with your options.
2nd line: our value (saved later in the options will implode by a comma like: 5,8,11,26,.. we need to explode this value to get the selected values back.
3rd line: this is needed for multiselect

The next plugin is called: admin_options_processing.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This plugin will implode our selected values with a comma.

Regards

Stoebi 10 Oct 2008 17:38

This is great. Thank you very much for sharing :)


Regards,

Stoebi

Blackhat 28 Oct 2008 14:52

can this be used in the user cp > options to make a "forum chooser" and which hook should I use?

ReCom 24 Nov 2008 09:31

A setting with datatype "bitfield" can create a group of checkboxes (multiselection) in vBulletin Options.

Coroner 18 Jul 2009 09:14

1 Attachment(s)
I didn't mean a forumchooser (Selectrow) or a multiple checkbox.

See image for the "multiselect field" what I mean.

Simon Lloyd 09 Oct 2013 01:07

The chooser code is great but i am unsure how to call it in a plug in, normally i'd have the user enter the forum id's and use something like $allowedforums = explode(",", $vbulletin->options['sens_forumid']);
if (in_array($threadinfo['forumid'], $allowedforums))

How do i use the information of the selected forums creating a multiselect like this?

ozzy47 09 Oct 2013 01:13

I believe what you are after is something this.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Simon Lloyd 09 Oct 2013 01:14

That works with the above?

ozzy47 09 Oct 2013 01:17

It should, the code I provided, works in my mods that I have a forum chooser in options, via a multi select field.

Simon Lloyd 09 Oct 2013 01:23

Hmmm, i tried a variation of the code i provided and it didnt work, the code you provided gives an error
Quote:

Parse error: syntax error, unexpected T_IF in /home/thecodec/public_html/forumz/showthread.php(112) : eval()'d code on line 31
--------------- Added 09 Oct 2013 at 01:25 ---------------

Errrr.....ummmm, guess who added an extra F to his own IF function!!!

My apologies!

ozzy47 09 Oct 2013 01:26

Ok here is how I do a forum chooser.

First create the option, and in the field, Option Code add the following:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then you will need to do the plugin for admin_options_processing

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then you can use the code I provided earlier.

Simon Lloyd 09 Oct 2013 01:35

Lol, thanks, did you see my note? :)

ozzy47 09 Oct 2013 01:37

Not until well after I had replied. :)

Easy5s.net 20 Jun 2015 11:45

Quote:

Originally Posted by ozzy47 (Post 2451071)
Ok here is how I do a forum chooser.

First create the option, and in the field, Option Code add the following:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then you will need to do the plugin for admin_options_processing

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then you can use the code I provided earlier.




Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

i user hook newthread_start with code


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

but not work :confused:


All times are GMT. The time now is 19:36.

Powered by vBulletin® Version 3.8.12
Copyright © 2019, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.