1. Home
  2. Car Demon Code Docs
  3. Admin Filters
  4. cd_settings_filter

cd_settings_filter

This filter can be used to modify the Car Demon settings array¬†when clicking “Update Settings” on the settings page. You can use this to add new items, remove items or update items that are part of the settings array.

apply_filters( ‘cd_settings_filter’, $settings );

add_action( 'cd_settings_filter', 'my_settings', 10, 1 );
function my_settings( $settings ) {

    $settings['my_setting'] = sanitize_text_field( $_POST['my_field'] );

    return $settings;
}

The above example would add an array key of “my_setting” to the Car Demon settings array and save the value $_POST[‘my_field’] – This is assume you’ve added a custom field to the setting page named “my_field”. This can be done by utilizing the action “cd_settings_action”.

Was this article helpful to you? Yes No

How can we help?