From 46406ea5720fbb71809cc9ea2b38658bb44faef3 Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Mon, 5 Sep 2016 22:47:01 +0800 Subject: [PATCH] Fix role field options --- core/um-fields.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/um-fields.php b/core/um-fields.php index 440a0795..9f9747a8 100644 --- a/core/um-fields.php +++ b/core/um-fields.php @@ -1613,23 +1613,23 @@ class UM_Fields { // role field if ( $form_key == 'role' ) { - global $wpdb; foreach($options as $key => $val ) { $val = (string) $val; $val = trim( $val ); $post_id = $wpdb->get_var( - $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'um_role' AND post_title = %s", $val) + $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'um_role' AND post_name = %s OR post_title = %s", $key, $val ) ); $_role = get_post( $post_id ); - $new_roles[ $_role->post_name ] = $_role->post_title; + if( isset( $_role->post_title ) ){ + $new_roles[ $_role->post_name ] = $_role->post_title; + } wp_reset_postdata(); } $options = $new_roles; } - // add an empty option! $output .= '';