• I wanna design a form with relationship for two value (Just like Country > State), when I select value1, that value2 will change to fit value1, I have Google that, it suggest me to use “Choice Callback”, I have tried to add my function into “functions.php” under my theme folder, and fill the “Choice Callback” blank with function name (without brackets), but it still doesn’t work, I opened the “Develop Tools” in Chrome when I select value1, and I saw a ajax request has been post, but the http status code is 400, and it response ‘0’, I’m very confused about that, I’ll be grateful if you guys know how to help me, thx.

Viewing 2 replies - 1 through 2 (of 2 total)
  • In case it helps, I ran into this 400 error here too and had to add a line to my functions file to allow this particular action to be allowed for unauthorized users:

    if(function_exists('UM')) {
        add_action('wp_ajax_nopriv_um_select_options', array(UM()->form(), 'ajax_select_options'));
    }

    A little kludgy, but it works.

    I would like to define the choice callback function in a class file of my plugin, sadly this is not working -> functions.php works perfect. Any idea?

    In my plugin file:

    
    function return_choices(){
        $list = array(
          'one',
          'two',
          'three'
        )
        return $list;
    }
    add_action( 'init', array( $this, 'return_choices') )
    

    Thank you.

    Regards,
    Patrick

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to use “Choice Callback”’ is closed to new replies.