Hi! I need to save contents of an API call after I hit "Save" button in admin dashboard.
In kfunctions.php i've added event listener but using code provided below I get pre-save field values but not current. Can someone give any hint?
In kfunctions.php i've added event listener but using code provided below I get pre-save field values but not current. Can someone give any hint?

- Code: Select all
$FUNCS->add_event_listener( 'page_saved', 'partial_cache' );
function partial_cache(){
global $PAGE, $CTX;
if ($PAGE->tpl_name == 'SOME_TEMPLATE') {
$longtitude = $CTX->get('map_longtitude');
$latitude = $CTX->get('map_latitude');
$map = file_get_contents("EXTERNAL_API_URL" . $longtitude . "," . $latitude);
file_put_contents( K_COUCH_DIR . "../" . "FILE_TO_SAVE" , $map);
}
}