diff --git a/includes/class-functions.php b/includes/class-functions.php
index 8d4b2dd5..c3362c4d 100644
--- a/includes/class-functions.php
+++ b/includes/class-functions.php
@@ -187,6 +187,76 @@ if ( ! class_exists( 'UM_Functions' ) ) {
return apply_filters( 'um_excluded_taxonomies', $taxes );
}
+ /**
+ * Output templates
+ *
+ * @access public
+ * @param string $template_name
+ * @param string $path (default: '')
+ * @param array $t_args (default: array())
+ * @param bool $echo
+ *
+ * @return string|void
+ */
+ function get_template( $template_name, $basename = '', $t_args = array(), $echo = false ) {
+ if ( ! empty( $t_args ) && is_array( $t_args ) ) {
+ extract( $t_args );
+ }
+
+ $path = '';
+ if( $basename ) {
+ $array = explode( '/', trim( $basename, '/' ) );
+ $path = $array[0];
+ }
+
+ $located = $this->locate_template( $template_name, $path );
+ if ( ! file_exists( $located ) ) {
+ _doing_it_wrong( __FUNCTION__, sprintf( '%s does not exist.', $located ), '2.1' );
+ return;
+ }
+
+ $located = apply_filters( 'um_get_template', $located, $template_name, $path, $t_args );
+
+ ob_start();
+ do_action( 'um_before_template_part', $template_name, $path, $located, $t_args );
+ include( $located );
+ do_action( 'um_after_template_part', $template_name, $path, $located, $t_args );
+ $html = ob_get_clean();
+
+ if ( ! $echo ) {
+ return $html;
+ } else {
+ echo $html;
+ }
+ }
+
+
+ /**
+ * Locate a template and return the path for inclusion.
+ *
+ * @access public
+ * @param string $template_name
+ * @param string $path (default: '')
+ * @return string
+ */
+ function locate_template( $template_name, $path = '' ) {
+ // check if there is template at theme folder
+ $template = locate_template( array(
+ trailingslashit( 'ultimate-member/' . $path ) . $template_name
+ ) );
+
+ if( !$template ) {
+ if( $path ) {
+ $template = trailingslashit( trailingslashit( WP_PLUGIN_DIR ) . $path );
+ } else {
+ $template = trailingslashit( um_path );
+ }
+ $template .= 'templates/' . $template_name;
+ }
+ // Return what we found.
+ return apply_filters( 'um_locate_template', $template, $template_name, $path );
+ }
+
}
}
\ No newline at end of file
diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php
index 26b1c3a6..fc025cb0 100644
--- a/includes/core/class-fields.php
+++ b/includes/core/class-fields.php
@@ -477,6 +477,12 @@
return $value;
+ } else if( isset( UM()->user()->profile[$key] ) ){
+
+ $value = UM()->user()->profile[$key];
+ $value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
+ return $value;
+
} else if ($default) {
$default = apply_filters( "um_field_default_value", $default, $data, $type );
@@ -1326,7 +1332,7 @@
$number_limit .= " max=\"{$max}\" ";
}
- $output .= '
+ $output .= '
';
@@ -2594,7 +2600,10 @@
if (in_array( $type, array( 'block', 'shortcode', 'spacing', 'divider', 'group' ) )) {
} else {
- if (!$this->field_value( $key, $default, $data )) return;
+
+ $_field_value = $this->field_value( $key, $default, $data );
+
+ if ( ! isset($_field_value) || $_field_value == '') return;
}
if (!um_can_view_field( $data )) return;
diff --git a/includes/core/class-members.php b/includes/core/class-members.php
index 6dd93f9f..84a53490 100644
--- a/includes/core/class-members.php
+++ b/includes/core/class-members.php
@@ -144,7 +144,8 @@ if ( ! class_exists( 'Members' ) ) {
* @since 1.3.83
*/
function um_search_select_fields( $attrs ) {
- if( strstr( $attrs['metakey'], 'role_' ) ){
+
+ if( !empty($attrs['metakey']) && strstr( $attrs['metakey'], 'role_' ) ){
$shortcode_roles = get_post_meta( UM()->shortcodes()->form_id, '_um_roles', true );
$um_roles = UM()->roles()->get_roles( false );
diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php
index a5d8c51a..87238bd1 100644
--- a/includes/core/um-filters-fields.php
+++ b/includes/core/um-filters-fields.php
@@ -482,3 +482,24 @@
return $value;
}
+ /**
+ * add role_select and role_radio to the $post_form
+ * It is necessary for that if on these fields the conditional logic
+ * @param $post_form array
+ * @param $mode
+ *
+ * @return $post_form
+ * @uses hook filters: um_submit_form_data
+ */
+ function um_submit_form_data_role_fields( $post_form, $mode ) {
+ $custom_fields = unserialize( $post_form['custom_fields'] );
+ if ( ! empty( $post_form['role'] ) && array_key_exists( 'role_select', $custom_fields ) ) {
+ $post_form['role_select'] = $post_form['role'];
+ }
+ if (! empty( $post_form['role'] ) && array_key_exists( 'role_radio', $custom_fields ) ) {
+ $post_form['role_radio'] = $post_form['role'];
+ }
+
+ return $post_form;
+ }
+ add_filter( 'um_submit_form_data', 'um_submit_form_data_role_fields', 10, 2 );
\ No newline at end of file