vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Insert a toggle in to User CP (https://vborg.vbsupport.ru/showthread.php?t=270209)

Shadow 09-13-2011 06:05 PM

Insert a toggle in to User CP
 
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:

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!


All times are GMT. The time now is 01:10 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01008 seconds
  • Memory Usage 1,717KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete