Better to avoid such a thing. The settings API has two “faces”, one the UI, and the other is handling the form submission. The form submission is handled on a different URL than the UI (/wp-admin/options.php
) and therefor your “user action” depended code will not run and the handling of storing the setting in the DB might fail.
You need to register properly all fields, and then you can use CSS or JS to show/hide the relevant UI.
Related Posts:
- Custom plugin settings: clicking “save changes” does not display success message
- How to get specific setting by settings_fields()?
- How to make sure settings are not lost when plugin is updated?
- How to save Setting pages data to the database?
- How to save the option’s new values plus old value without overwrite old one
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- How do I add a textarea (multirow) option to my WordPress plugin?
- Validating values using Settings API?
- move setting data from wordpress api to codestar freamwork
- Where can I find a schema of wordpress plugin core architecture?
- How to Loop Plugin Option Field Set?
- How to find out if option exists but is empty?
- How should I use register_setting, add_settings_section, & add_settings_field in my plugin’s options page?
- How to handel multiple checkbox field in the admin settings page with Settings API
- How can I include a setting that has a variable number of values in a settings page using register_setting?
- Saving Plugin settings to the database
- How to fetch serialized data from wordpress options
- Get all options saved by another plugin
- Add a Custom Permalink option in the Permalink Admin Screen?
- Settings API – input always updates over validation
- add action wp_head not working
- Wp die causing 500 Internal Server Error?
- Why is the Settings API is not saving my array of options
- Can’t get plugin settings page to save data
- Default Plugin Settings Not Writing to Database
- Update Option Error: Notice: Undefined index
- Why this global array is returning NULL from a callback function
- Serialize data for wp options
- How can I add an options page for my class based plugin?
- Get plugin option in another PHP file
- Add Plugin options as subpage to Theme options page
- Show admin notice on incorrect value on form field
- php page not found for plugin options menu
- Checkbox conflict in my custom plugin admin page
- add tabs in rdp-plugin/includes/settings.php and get settings saved
- Change the display of Settings API (do_settings_sections)
- Redirect to another page using contact form 7? [closed]
- Settings API saved values not getting shown in the dropdownbox
- WordPress error: Options page Setting_ not found in the allowed options list
- update_option_{$option} not showing old value
- How to prevent plugins from sniffing/stealing other plugins’ options?
- get_option / wp_localize_script Not Working in OOP Plug In
- Update WP option by plugin
- How to save plugin custom settings page fields
- Need to add/remove group of options and display them as rows
- How to get values from network settings panel?
- wp_options not returning value for logged out users?
- Problem with MEMCACHE and Redis with wp_options
- Plugin Options Page and Subpage
- WP options plugin setting not saving the selected checkboxes
- Echo custom admin field into a is_single()
- Protect WordPress option value
- Why is the WordPress update_option not working in this code?
- How to create a new database table whenever user changes options
- Option page not updating multiple records in settings api
- Create Array from data in the OPTIONS table
- Saving an array to get_options
- Building a simple “settings” plugin to change textstrings on the home page
- My first plugin doesn’t save the data in options
- How to access values from your own settings page in javascript?
- Pass PHP variable to javascript
- Namespaces in WordPress – How do I initiate the main class?
- What areas to Unit test while building a plugin?
- Why won’t register_setting() create a setting?
- Pass A Value From Outside To A Plugin Variable
- How to handle autoloading with composer by keeping the WordPress naming conventions?
- Current user in plugin returns NULL
- What are the benefit in adding hook in the init() hook?
- How can I implement a notification system in wordpress?
- Minimum PHP Required for WordPress
- Create entire wordpress as a github repositery?
- Conditional attributes and logic per product category
- Displaying Custom Sidebar Without Modifying Theme’s Core File?
- Custom license for WordPress plugin
- Does using `add_action( ‘init’…` cause performance issues?
- How to write “alt” tag in image for wordpress code?
- How to create plugin/ page that reads from database
- Plugin not properly prepared for localization
- WordPress Active Plugins
- is it possible to hook every page style?
- Redirect logged in user to somepage on every page view?
- How to add filter for wordpress plugin?
- Adding a jQuery modal dialog to the admin area
- How to upload large media file in chunks, without any plugin?
- Cannot run script properly with my custom plugin
- Cookie value changes back to previous value after changing
- How to use functions found inside pluggable.php with my plugin files
- Is it okay to make a plugin to the WordPress repo, but limit it’s actions to maximum N events?
- Highlight admin menu items that are parent of existing core items
- Getting all woocommerce products from REST API call in plugin
- AJAX update fails for public/non-admin users
- WordPress Product Detail and catalog
- Create Database Tables on Plugin Activation hook
- Change page according to fetched GET Parameters
- Add_menu_page and saving settings
- How to change a specific page to custom page?
- Plugin keeps saying needs to be updated and it’s in a constant loop [closed]
- How use Dynamic hyperlink on each wordpress post?
- Plugin Block at the backend of every page or post
- How to provide page_template path in custom plugin using WordPress