Skip to content

Latest commit

 

History

History
21 lines (13 loc) · 769 Bytes

alch_value_option_id.md

File metadata and controls

21 lines (13 loc) · 769 Bytes

alch_value_{ $optionID }

Dynamic filter alch_value_{ $optionID } is used to filter the value for a given field before returning it from alch_get_option. It isn't applied to the $default parameter if the field has no value stored.

The $optionID should match one of the IDs in the configuration object.

Example

Say you want to tweak the URL field with the ID of my-url-field to convert the http protocol to https.

//somewhere in functions.php

function tweak_url_field( $value ) {
    // do not forget to pass it further
    return str_replace( "http://", "https://", $value );
}

add_filter( 'alch_value_my-url-field', 'tweak_url_field' );