Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ajax_getchoices_fromfield() {
- global $wpdb;
- $form_id = false;
- if(strip_tags($_POST['adminLabel'])){
- $adminLabel = strip_tags($_POST['adminLabel']);
- }
- if(intval($_POST['form_id'])){
- $form_id = intval($_POST['form_id']);
- }
- if(isset($adminLabel) && $form_id > 0){
- $choices = array();
- // get the choices from a hidden admin-only field
- //$result = $wpdb->get_row("SELECT display_meta FROM med_rg_form_meta WHERE form_id = ".(int)$form_id, ARRAY_A);
- //$display_meta = unserialize($result['display_meta']);
- $display_meta = GFAPI::get_form($form_id);// switched to use the GF API
- if(!empty($display_meta['fields'])){
- foreach($display_meta['fields'] as $key=>$field){
- // pull out just the hidden admin-only coupon codes, or whichever adminlabel
- if($field['adminOnly']==1 && $field['adminLabel']==$adminLabel){
- $choices = $field['choices'];
- }
- }
- }
- if(!empty($choices)){
- echo json_encode($choices);
- }
- }
- exit;
- }
- add_action('wp_ajax_getchoices_fromfield', 'ajax_getchoices_fromfield');
- add_action('wp_ajax_nopriv_getchoices_fromfield', 'ajax_getchoices_fromfield');//for users that are not logged in.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement