The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How can I check a custom option before saving?
Hello everyone, I was wondering if someone could please help me in a concern I am having with one of my custom options I created. Allow me to explain;
I have the following options: Option A: yes no Option A1: blah1 Option A2: blah2 Option A3: blah3 I want to be able to force the user to fill out options A1, A2, and A3 if they click yes for option A. I have an option that if turned on or selected yes, 3 other options have to be filled out for the option to execute correctly so I don't want the user to be able to save if the other 3 options have not been filled out yet. Is there any way I can get this done? I would imagine I can use a code in the Validation php code filed , some sort of if condition maybe? I am just not entirely sure how to go about it. If anyone can shed any light on this matter or can provide any more info it would be very much appreciated as always. Thanks for your time everyone. |
#2
|
|||
|
|||
If you create a plugin using hook profile_updateoptions, you can check the values and if they aren't correct, call eval(standard_error()), like
PHP Code:
Look in profile.php, search for fetch_hook('profile_updateoptions') (around line 2411) to see how the values are stored. |
#3
|
|||
|
|||
Quote:
|
#4
|
|||
|
|||
hmm...validation code? Maybe I misunderstood and we're talking about different kinds of options.
|
#5
|
|||
|
|||
I was talking about the options (custom options) you can create when in debug mode from the admin panel under "Settings".
|
#6
|
|||
|
|||
Oh...my mistake, I thought you meant custom profile fields. So what I posted above is useless. I don't have time right now but I'll look in to it later if you don't have an answer yet.
|
#7
|
|||
|
|||
xD Thanks kh99, it's ok. Please let me know if you find an answer when you have a chance, you know where to find me .
|
#8
|
|||
|
|||
Personally I think you're best off using a plugin to check values and throw the error.
Hook the plugin to admin_options_processing and compare $settings['your_setting_name'] and throw the error if it's not correct or empty. I don't know if that's the absolute correct hook, but I think it will work. Otherwise, you have to intercept $data before it's written to the settings database. |
#9
|
|||
|
|||
Quote:
PHP Code:
|
#10
|
|||
|
|||
What you have is probably the best way to keep invalid values from being saved. The PHP Validation code will allow you to check a value and print a message under it if it's invalid, but it will still be saved (maybe you knew that already and that's why you created the thread).
What you might be able to do in your plugin is print an error message then redirect back to the option page like: PHP Code:
(You'd want to use a real error phrase name, but I'm not sure of the other parameters you'd want). I don't think there's any easy way to get the error message to display under the value unless you let it save the invalid values (that is a reasonable option - you could check the values the mod code and use defaults if they're invalid, put in PHP validation code for your fields, and then whenever someone goes to the adminCP they'll see the error message). |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|