Home › Forums › Backend Issues (wp-admin) › Location value disappear › Reply To: Location value disappear
Ok, seems that a call to wp ajax into the functions.php caused the problem.
I had this code into functions.php used to process data for a form:
// this hook is fired if the current viewer is not logged in
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
// if logged in:
do_action( 'wp_ajax_' . $_POST['action'] );
add_action( 'wp_ajax_nopriv_gfl', 'gfl' );
add_action( 'wp_ajax_gfl', 'gfl' );
function gfl() {
if (isset($_POST['id'])){
$id = $_POST['id'];
$tr_type = get_tr_type($id);
echo $tr_type;
}else if(isset($_POST['to_id'])){
$id = $_POST['to_id'];
$tr_type = get_tr_type($id);
echo $tr_type;
}
exit;
}
add_action( 'wp_ajax_nopriv_gtl', 'gtl' );
add_action( 'wp_ajax_gtl', 'gtl' );
function gtl() {
$from_id = $_POST['id'];
$to_id = $_POST['to_id'];
get_to_locations($from_id,$to_id);
exit;
}
Now i’ve wrapped this code between an is_admin() condition:
if (!is_admin()) { // Ajax Code }
Seems that the location is now working well.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.