Support

Account

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.