Function Reference: geodir_search_duplicate_field
Summary
This function has not been documented yet.
Source File
geodir_search_duplicate_field() is located in geodir_ajax_duplicate_alert/geodir_ajax_duplicate_alert.php [Line: 136]
Source Code
function geodir_search_duplicate_field(){
global $wpdb, $plugin_prefix;
$field = $_REQUEST['field'];
$post_type = $_REQUEST['post_type'];
if (isset($_REQUEST['search_val'])) {
$search = htmlentities($_REQUEST['search_val']);
} else $search ='';
if($search){
$table = $plugin_prefix.$post_type.'_detail';
if($wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM ".$table." WHERE field = %s", array($field)))){
$query = $wpdb->prepare("SELECT d.".$field." FROM $wpdb->posts p, ".$table." d WHERE p.ID=d.post_id AND d.".$field."=%s AND p.post_type=%s AND p.post_status='publish'", array($search, $post_type));
$results = $wpdb->get_results( $query );
if(count($results) > 0){
$post_types = geodir_get_posttypes('object');
$name = $post_types->$post_type->labels->singular_name;
echo __('A', GEODIRDUPLICATEALERT_TEXTDOMAIN ).' '.ucfirst($name).__(' with this field is already listed!
Please make sure you are not adding a duplicate entry', GEODIRDUPLICATEALERT_TEXTDOMAIN);
}
}
}
}