Last active
February 6, 2023 19:40
-
-
Save raftaar1191/955454be353832f5af7c479e544d17f6 to your computer and use it in GitHub Desktop.
Carbon Fields knows if these is a hook that triggers before the field is saved and has both the new and old values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the value before the save run | |
*/ | |
function carbon_fields_should_save_field_value_callback( $save, $value, $field ) { | |
$fields_id = 'crb_text'; | |
error_log( print_r( carbon_get_theme_option( $fields_id ), true ) . "\n", 3, WP_CONTENT_DIR . '/debug_new1.log' ); | |
error_log( print_r( $value, true ) . "\n", 3, WP_CONTENT_DIR . '/debug_new1.log' ); | |
return $save; | |
} | |
add_filter( 'carbon_fields_should_save_field_value', 'carbon_fields_should_save_field_value_callback', 1, 3 ); | |
/** | |
* Do not delete the value before it get saved | |
*/ | |
add_filter( 'carbon_fields_should_delete_field_value_on_save', '__return_false' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fields registered
https://docs.carbonfields.net/quickstart.html