我想实现以下目标:
即使梳理了在线文档并尝试了几种方法,我也无法使条件重定向生效。我的无效代码是:
//Select custom single variable data function select_var($sql, $offset = 0) { global $wpdb; $data = $wpdb->get_col($sql); return $data; } //Form processor function form_processor($form_data) { global $wpdb; $siteurl = get_bloginfo('url') . '/'; $form_fields = $form_data['fields']; $data = array(); foreach($form_fields as $field) { $field_key = $field['key']; $field_value = $field['value']; } // Search $name = 'some_name'; $search = select_var($wpdb->prepare("SELECT `name` FROM `$wpdb->prefix" . "table` WHERE `name` = %s", $name)); if(search[0]) { $redirect_url = $siteurl . "success/"; wp_redirect($redirect_url); exit; } else { $redirect_url = $siteurl . "form/"; wp_redirect($redirect_url); exit; } } add_action('ninja_forms_processing', 'form_processor'); //WP Hook in the form
在此先感谢您的帮助或指示。