PDA

View Full Version : Insert a toggle in to User CP


Shadow
09-13-2011, 06:05 PM
I think this is the right place to post this.

Basically, i want to edit a plugin so that it's feature can be toggled on and off from the User CP depending on the user's choice. So i was wondering if someone could help me to achieve this?

Any help is appreciated.

kh99
09-14-2011, 10:41 AM
- Under "User Profile Fields" in the adminCP, add your new profile field
- in the plugin, check the value of $vbulletin->userinfo['fieldX'], where X is the number of the profile field you've created.

Shadow
09-16-2011, 05:56 AM
Alright thanks. I'm just abit confused on the 2nd step. I'm new to this vb4 programming..

What would the code be to have the mod disabled for that user depending on the value of the profile field?

kh99
09-16-2011, 06:54 AM
OK, well, let's say you create a single-selection radio button option "Enable this feature" with the options 'Yes' and 'No'. Then you would edit the plugin and add this code:

if ($vbulletin->userinfo['fieldX'] == 'Yes')
{
(existing plugin code)
}


You'd have to do the same for each plugin if there is more than one.

(Also: the code may or may not need a "global $vbulletin;" line at the beginning, depending on the hook location. It doesn't hurt to have it even if it's not needed).

Shadow
09-16-2011, 08:01 AM
Ah i get it. Thanks alot mate! Your help is greatly appreciated!

EDIT: Okay, i tried editing the plugin code and i did everything as you told me but it doesn't work. The plugin's function doesn't take effect. I've also tried adding 'global $vbulletin;' but no luck.

If you want, i could post the code for you to see?

kh99
09-16-2011, 10:50 AM
You could post the code you added - don't post the entire plugin code. Also, let us know what hook location the plugin is using.

Shadow
09-16-2011, 02:41 PM
Sorry, i checked again and now it's working. Must've not taken effect straight away earlier but now it's working. Thanks alot pal!