From 748ebf5fa9ae449bd704de22292870cde182fc0c Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Fri, 14 Aug 2020 19:15:38 +0300 Subject: [PATCH] - updated Info window fields (hide fields without metakeys); --- includes/um-deprecated-functions.php | 106 ++++++++++++++++++++++++ includes/um-short-functions.php | 115 ++------------------------- 2 files changed, 114 insertions(+), 107 deletions(-) diff --git a/includes/um-deprecated-functions.php b/includes/um-deprecated-functions.php index 8f8a0eab..5c9ee973 100644 --- a/includes/um-deprecated-functions.php +++ b/includes/um-deprecated-functions.php @@ -576,4 +576,110 @@ function um_select_if_in_query_params( $filter, $val ) { } echo $selected ? 'selected="selected"' : ''; +} + + +/** + * Get submitted user information + * + * @param bool $style + * + * @return null|string + * + * @deprecated 2.1.3 + */ +function um_user_submitted_registration( $style = false ) { + $output = null; + + $data = um_user( 'submitted' ); + + if ( $style ) { + $output .= '
'; + } + + if ( isset( $data ) && is_array( $data ) ) { + + /** + * UM hook + * + * @type filter + * @title um_email_registration_data + * @description Prepare Registration data to email + * @input_vars + * [{"var":"$data","type":"array","desc":"Registration Data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_email_registration_data', 'function_name', 10, 1 ); + * @example + * + */ + $data = apply_filters( 'um_email_registration_data', $data ); + + $pw_fields = array(); + foreach ( $data as $k => $v ) { + + if ( strstr( $k, 'user_pass' ) || in_array( $k, array( 'g-recaptcha-response', 'request', '_wpnonce', '_wp_http_referer' ) ) ) { + continue; + } + + if ( UM()->fields()->get_field_type( $k ) == 'password' ) { + $pw_fields[] = $k; + $pw_fields[] = 'confirm_' . $k; + continue; + } + + if ( ! empty( $pw_fields ) && in_array( $k, $pw_fields ) ) { + continue; + } + + if ( UM()->fields()->get_field_type( $k ) == 'image' || UM()->fields()->get_field_type( $k ) == 'file' ) { + $file = basename( $v ); + $filedata = get_user_meta( um_user( 'ID' ), $k . "_metadata", true ); + + $baseurl = UM()->uploader()->get_upload_base_url(); + if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $file ) ) { + if ( is_multisite() ) { + //multisite fix for old customers + $baseurl = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $baseurl ); + } + } + + if ( ! empty( $filedata['original_name'] ) ) { + $v = '' . esc_html( $filedata['original_name'] ) . ''; + } else { + $v = $baseurl . um_user( 'ID' ) . '/' . $file; + } + } + + if ( is_array( $v ) ) { + $v = implode( ',', $v ); + } + + if ( $k == 'timestamp' ) { + $k = __( 'date submitted', 'ultimate-member' ); + $v = date( "d M Y H:i", $v ); + } + + if ( $style ) { + if ( ! $v ) { + $v = __( '(empty)', 'ultimate-member' ); + } + $output .= "

$v

"; + } else { + $output .= "$k: $v" . "
"; + } + } + } + + if ( $style ) { + $output .= '
'; + } + + return $output; } \ No newline at end of file diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index d187b42a..79896e4d 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -666,111 +666,6 @@ function um_get_snippet( $str, $wordCount = 10 ) { } -/** - * Get submitted user information - * - * @param bool $style - * - * @return null|string - * - * @deprecated 2.1.3 - */ -function um_user_submitted_registration( $style = false ) { - $output = null; - - $data = um_user( 'submitted' ); - - if ( $style ) { - $output .= '
'; - } - - if ( isset( $data ) && is_array( $data ) ) { - - /** - * UM hook - * - * @type filter - * @title um_email_registration_data - * @description Prepare Registration data to email - * @input_vars - * [{"var":"$data","type":"array","desc":"Registration Data"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_email_registration_data', 'function_name', 10, 1 ); - * @example - * - */ - $data = apply_filters( 'um_email_registration_data', $data ); - - $pw_fields = array(); - foreach ( $data as $k => $v ) { - - if ( strstr( $k, 'user_pass' ) || in_array( $k, array( 'g-recaptcha-response', 'request', '_wpnonce', '_wp_http_referer' ) ) ) { - continue; - } - - if ( UM()->fields()->get_field_type( $k ) == 'password' ) { - $pw_fields[] = $k; - $pw_fields[] = 'confirm_' . $k; - continue; - } - - if ( ! empty( $pw_fields ) && in_array( $k, $pw_fields ) ) { - continue; - } - - if ( UM()->fields()->get_field_type( $k ) == 'image' || UM()->fields()->get_field_type( $k ) == 'file' ) { - $file = basename( $v ); - $filedata = get_user_meta( um_user( 'ID' ), $k . "_metadata", true ); - - $baseurl = UM()->uploader()->get_upload_base_url(); - if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $file ) ) { - if ( is_multisite() ) { - //multisite fix for old customers - $baseurl = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $baseurl ); - } - } - - if ( ! empty( $filedata['original_name'] ) ) { - $v = '' . esc_html( $filedata['original_name'] ) . ''; - } else { - $v = $baseurl . um_user( 'ID' ) . '/' . $file; - } - } - - if ( is_array( $v ) ) { - $v = implode( ',', $v ); - } - - if ( $k == 'timestamp' ) { - $k = __( 'date submitted', 'ultimate-member' ); - $v = date( "d M Y H:i", $v ); - } - - if ( $style ) { - if ( ! $v ) { - $v = __( '(empty)', 'ultimate-member' ); - } - $output .= "

$v

"; - } else { - $output .= "$k: $v" . "
"; - } - } - } - - if ( $style ) { - $output .= '
'; - } - - return $output; -} - /** * Format submitted data for Info preview & Email template * @param boolean $style @@ -941,7 +836,7 @@ function um_user_submitted_registration_formatted( $style = false ) { function um_user_submited_display( $k, $title, $data = array(), $style = true ) { $output = ''; - if ( 'form_id' == $k && isset( $data['form_id'] ) && ! empty( $data['form_id'] ) ) { + if ( 'form_id' == $k && isset( $data['form_id'] ) && ! empty( $data['form_id'] ) ) { $v = sprintf( __( '%s - Form ID#: %s', 'ultimate-member' ), get_the_title( $data['form_id'] ), $data['form_id'] ); } else { $v = um_user( $k ); @@ -951,6 +846,12 @@ function um_user_submited_display( $k, $title, $data = array(), $style = true ) return ''; } + $fields_without_metakey = UM()->builtin()->get_fields_without_metakey(); + $type = UM()->fields()->get_field_type( $k ); + if ( in_array( $type, $fields_without_metakey ) ) { + return ''; + } + if ( ! $v ) { if ( $style ) { return "

" . __( '(empty)', 'ultimate-member' ) ."

"; @@ -959,7 +860,7 @@ function um_user_submited_display( $k, $title, $data = array(), $style = true ) } } - if ( UM()->fields()->get_field_type( $k ) == 'image' || UM()->fields()->get_field_type( $k ) == 'file' ) { + if ( $type == 'image' || $type == 'file' ) { $file = basename( $v ); $filedata = get_user_meta( um_user( 'ID' ), $k . "_metadata", true );