mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Merge branch 'development/2.8.x' into feature/search_exclude_fields
This commit is contained in:
@@ -1772,10 +1772,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
$access = UM()->options()->get( 'accessible' );
|
||||
|
||||
if ( $access == 2 ) {
|
||||
//global settings for accessible home page
|
||||
// Global settings for accessible home page
|
||||
$home_page_accessible = UM()->options()->get( 'home_page_accessible' );
|
||||
|
||||
if ( $home_page_accessible == 0 ) {
|
||||
if ( ! $home_page_accessible ) {
|
||||
//get redirect URL if not set get login page by default
|
||||
$redirect = UM()->options()->get( 'access_redirect' );
|
||||
if ( ! $redirect ) {
|
||||
@@ -1795,9 +1795,9 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
$access = UM()->options()->get( 'accessible' );
|
||||
|
||||
if ( $access == 2 ) {
|
||||
//global settings for accessible home page
|
||||
// Global settings for accessible home page
|
||||
$category_page_accessible = UM()->options()->get( 'category_page_accessible' );
|
||||
if ( $category_page_accessible == 0 ) {
|
||||
if ( ! $category_page_accessible ) {
|
||||
//get redirect URL if not set get login page by default
|
||||
$redirect = UM()->options()->get( 'access_redirect' );
|
||||
if ( ! $redirect ) {
|
||||
|
||||
@@ -576,7 +576,7 @@ if ( ! class_exists( 'um\core\Account' ) ) {
|
||||
|
||||
case 'privacy':
|
||||
|
||||
$args = 'profile_privacy,profile_noindex,hide_in_members';
|
||||
$args = 'profile_privacy,profile_noindex,hide_in_members,um_show_last_login';
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
|
||||
@@ -273,7 +273,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
),
|
||||
|
||||
'tel' => array(
|
||||
'name' => __( 'Telephone Box', 'ultimate-member' ),
|
||||
'name' => __( 'Telephone', 'ultimate-member' ),
|
||||
'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
|
||||
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
|
||||
'col3' => array('_required','_editable','_icon'),
|
||||
@@ -782,10 +782,10 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
),
|
||||
|
||||
'username' => array(
|
||||
'title' => __('Username or E-mail','ultimate-member'),
|
||||
'title' => __('Username or Email','ultimate-member'),
|
||||
'metakey' => 'username',
|
||||
'type' => 'text',
|
||||
'label' => __('Username or E-mail','ultimate-member'),
|
||||
'label' => __('Username or Email','ultimate-member'),
|
||||
'required' => 1,
|
||||
'public' => 1,
|
||||
'editable' => false,
|
||||
@@ -871,10 +871,10 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
),
|
||||
|
||||
'user_email' => array(
|
||||
'title' => __('E-mail Address','ultimate-member'),
|
||||
'title' => __('Email Address','ultimate-member'),
|
||||
'metakey' => 'user_email',
|
||||
'type' => 'text',
|
||||
'label' => __('E-mail Address','ultimate-member'),
|
||||
'label' => __('Email Address','ultimate-member'),
|
||||
'required' => 0,
|
||||
'public' => 1,
|
||||
'validate' => 'unique_email',
|
||||
@@ -882,10 +882,10 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
),
|
||||
|
||||
'secondary_user_email' => array(
|
||||
'title' => __('Secondary E-mail Address','ultimate-member'),
|
||||
'title' => __('Secondary Email Address','ultimate-member'),
|
||||
'metakey' => 'secondary_user_email',
|
||||
'type' => 'text',
|
||||
'label' => __('Secondary E-mail Address','ultimate-member'),
|
||||
'label' => __('Secondary Email Address','ultimate-member'),
|
||||
'required' => 0,
|
||||
'public' => 1,
|
||||
'editable' => true,
|
||||
@@ -1271,7 +1271,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
),
|
||||
|
||||
'username_b' => array(
|
||||
'title' => __('Username or E-mail','ultimate-member'),
|
||||
'title' => __('Username or Email','ultimate-member'),
|
||||
'metakey' => 'username_b',
|
||||
'type' => 'text',
|
||||
'placeholder' => __('Enter your username or email','ultimate-member'),
|
||||
@@ -1336,6 +1336,23 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
'required_opt' => array( 'members_page', true ),
|
||||
),
|
||||
|
||||
'um_show_last_login' => array(
|
||||
'title' => __( 'Show my last login?', 'ultimate-member' ),
|
||||
'metakey' => 'um_show_last_login',
|
||||
'type' => 'radio',
|
||||
'label' => __( 'Show my last login?', 'ultimate-member' ),
|
||||
'help' => __( 'Here you can hide last login field on profile page and card in member directory', 'ultimate-member' ),
|
||||
'required' => 0,
|
||||
'public' => 1,
|
||||
'editable' => true,
|
||||
'default' => 'yes',
|
||||
'options' => array(
|
||||
'no' => __( 'No', 'ultimate-member' ),
|
||||
'yes' => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
'account_only' => true,
|
||||
),
|
||||
|
||||
'delete_account' => array(
|
||||
'title' => __( 'Delete Account', 'ultimate-member' ),
|
||||
'metakey' => 'delete_account',
|
||||
@@ -1558,11 +1575,11 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
$array['skype'] = __('Skype ID','ultimate-member');
|
||||
$array['soundcloud'] = __( 'SoundCloud Profile', 'ultimate-member' );
|
||||
$array['twitter_url'] = __( 'X (formerly Twitter) URL', 'ultimate-member' );
|
||||
$array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
|
||||
$array['unique_email'] = __('Unique E-mail','ultimate-member');
|
||||
$array['is_email'] = __('Email( Not Unique )','ultimate-member');
|
||||
$array['unique_email'] = __('Unique Email','ultimate-member');
|
||||
$array['unique_value'] = __('Unique Metakey value','ultimate-member');
|
||||
$array['unique_username'] = __('Unique Username','ultimate-member');
|
||||
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
||||
$array['unique_username_or_email'] = __('Unique Username/Email','ultimate-member');
|
||||
$array['url'] = __('Website URL','ultimate-member');
|
||||
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
||||
$array['youtube_video'] = __('YouTube Video','ultimate-member');
|
||||
|
||||
@@ -604,7 +604,7 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) {
|
||||
*/
|
||||
function render_status_icon( $link, $text, $img ) {
|
||||
|
||||
$icon_html = '<a href="' . $link . '" title="' . $text . '">';
|
||||
$icon_html = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $text ) . '">';
|
||||
$icon_html .= '<img style="padding:1px;margin:2px;" border="0" src="'
|
||||
. ICL_PLUGIN_URL . '/res/img/'
|
||||
. $img . '" alt="'
|
||||
|
||||
@@ -623,7 +623,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* @return string
|
||||
*/
|
||||
public function show_error( $key ) {
|
||||
return UM()->form()->errors[ $key ];
|
||||
if ( empty( UM()->form()->errors ) ) {
|
||||
return '';
|
||||
}
|
||||
return array_key_exists( $key, UM()->form()->errors ) ? UM()->form()->errors[ $key ] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -634,7 +637,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* @return string
|
||||
*/
|
||||
public function show_notice( $key ) {
|
||||
return UM()->form()->notices[ $key ];
|
||||
if ( empty( UM()->form()->notices ) ) {
|
||||
return '';
|
||||
}
|
||||
return array_key_exists( $key, UM()->form()->notices ) ? UM()->form()->notices[ $key ] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -647,13 +653,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* @return string
|
||||
*/
|
||||
public function field_label( $label, $key, $data ) {
|
||||
$output = null;
|
||||
$output .= '<div class="um-field-label">';
|
||||
|
||||
if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'off' !== $this->field_icons && ( 'label' === $this->field_icons || true === $this->viewing ) ) {
|
||||
$output .= '<div class="um-field-label-icon"><i class="' . esc_attr( $data['icon'] ) . '" aria-label="' . esc_attr( $label ) . '"></i></div>';
|
||||
}
|
||||
|
||||
if ( true === $this->viewing ) {
|
||||
/**
|
||||
* Filters Ultimate Member field label on the Profile form: View mode.
|
||||
@@ -724,13 +723,26 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
|
||||
}
|
||||
|
||||
$output = null;
|
||||
$output .= '<div class="um-field-label">';
|
||||
|
||||
if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && 'off' !== $this->field_icons && ( 'label' === $this->field_icons || true === $this->viewing ) ) {
|
||||
$output .= '<div class="um-field-label-icon"><i class="' . esc_attr( $data['icon'] ) . '" aria-label="' . esc_attr( $label ) . '"></i></div>';
|
||||
}
|
||||
|
||||
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
||||
$for_attr = '';
|
||||
if ( ! in_array( $data['type'], $fields_without_metakey, true ) ) {
|
||||
$for_attr = ' for="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
||||
}
|
||||
|
||||
$output .= '<label' . $for_attr . '>' . __( $label, 'ultimate-member' ) . '</label>';
|
||||
$output .= '<label' . $for_attr . '>' . esc_html__( $label, 'ultimate-member' );
|
||||
|
||||
if ( ! empty( $data['required'] ) && UM()->options()->get( 'form_asterisk' ) ) {
|
||||
$output .= '<span class="um-req" title="' . esc_attr__( 'Required', 'ultimate-member' ) . '">*</span>';
|
||||
}
|
||||
|
||||
$output .= '</label>';
|
||||
|
||||
if ( ! empty( $data['help'] ) && false === $this->viewing && false === strpos( $key, 'confirm_user_pass' ) ) {
|
||||
if ( ! UM()->mobile()->isMobile() ) {
|
||||
@@ -3086,7 +3098,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$fonticon = UM()->files()->get_fonticon_by_ext( $file_type['ext'] );
|
||||
|
||||
$output .= '<div class="um-single-fileinfo">';
|
||||
$output .= '<a href="' . esc_attr( $file_url ) . '" target="_blank">';
|
||||
$output .= '<a href="' . esc_url( $file_url ) . '" target="_blank">';
|
||||
$output .= '<span class="icon" style="background:' . esc_attr( $fonticon_bg ) . '"><i class="' . esc_attr( $fonticon ) . '"></i></span>';
|
||||
$output .= '<span class="filename">' . esc_html( $file_field_name ) . '</span>';
|
||||
$output .= '</a></div></div>';
|
||||
@@ -4272,6 +4284,14 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function view_field( $key, $data, $rule = false ) {
|
||||
if ( '_um_last_login' === $key ) {
|
||||
$profile_id = um_user( 'ID' );
|
||||
$show_last_login = get_user_meta( $profile_id, 'um_show_last_login', true );
|
||||
if ( ! empty( $show_last_login ) && 'no' === $show_last_login[0] ) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
// Get whole field data.
|
||||
|
||||
@@ -351,8 +351,8 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
|
||||
*/
|
||||
$message = apply_filters( 'um_email_send_message_content', $message, $slug, $args );
|
||||
|
||||
add_filter( 'um_template_tags_patterns_hook', array( &$this, 'add_placeholder' ) );
|
||||
add_filter( 'um_template_tags_replaces_hook', array( &$this, 'add_replace_placeholder' ) );
|
||||
// add_filter( 'um_template_tags_patterns_hook', array( &$this, 'add_placeholder' ) );
|
||||
// add_filter( 'um_template_tags_replaces_hook', array( &$this, 'add_replace_placeholder' ) );
|
||||
|
||||
// Convert tags in email template.
|
||||
return um_convert_tags( $message, $args );
|
||||
@@ -421,8 +421,8 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
|
||||
$mail_from_addr = UM()->options()->get( 'mail_from_addr' ) ? UM()->options()->get( 'mail_from_addr' ) : get_bloginfo( 'admin_email' );
|
||||
$this->headers = 'From: ' . stripslashes( $mail_from ) . ' <' . $mail_from_addr . '>' . "\r\n";
|
||||
|
||||
add_filter( 'um_template_tags_patterns_hook', array( UM()->mail(), 'add_placeholder' ) );
|
||||
add_filter( 'um_template_tags_replaces_hook', array( UM()->mail(), 'add_replace_placeholder' ) );
|
||||
add_filter( 'um_template_tags_patterns_hook', array( $this, 'add_placeholder' ) );
|
||||
add_filter( 'um_template_tags_replaces_hook', array( $this, 'add_replace_placeholder' ) );
|
||||
|
||||
/**
|
||||
* Filters email notification subject.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -58,7 +58,11 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
var $filter_types = array();
|
||||
|
||||
|
||||
/**
|
||||
* Fields used for searching from wp_users table.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
var $core_search_fields = array(
|
||||
'user_login',
|
||||
'user_url',
|
||||
@@ -67,6 +71,19 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
'user_nicename',
|
||||
);
|
||||
|
||||
/**
|
||||
* Fields used for sorting from wp_users table.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
var $core_users_fields = array(
|
||||
'user_login',
|
||||
'user_url',
|
||||
'display_name',
|
||||
'user_email',
|
||||
'user_nicename',
|
||||
'user_registered',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var
|
||||
@@ -408,7 +425,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
'first_name' => __( 'First Name', 'ultimate-member' ),
|
||||
'last_name' => __( 'Last Name', 'ultimate-member' ),
|
||||
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
||||
'secondary_user_email' => __( 'Secondary E-mail Address', 'ultimate-member' ),
|
||||
'secondary_user_email' => __( 'Secondary Email Address', 'ultimate-member' ),
|
||||
'description' => __( 'Biography', 'ultimate-member' ),
|
||||
'phone_number' => __( 'Phone Number', 'ultimate-member' ),
|
||||
'mobile_number' => __( 'Mobile Number', 'ultimate-member' ),
|
||||
@@ -1314,24 +1331,24 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$this->query_args['paged'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add sorting attributes for \WP_Users_Query
|
||||
*
|
||||
* @param array $directory_data Member Directory options
|
||||
*/
|
||||
function sorting_query( $directory_data ) {
|
||||
public function sorting_query( $directory_data ) {
|
||||
// sort members by
|
||||
$this->query_args['order'] = 'ASC';
|
||||
|
||||
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
|
||||
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
|
||||
$sortby = ( 'other' === $sortby ) ? $directory_data['sortby_custom'] : $sortby;
|
||||
|
||||
$custom_sort = array();
|
||||
if ( ! empty( $directory_data['sorting_fields'] ) ) {
|
||||
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
|
||||
foreach ( $sorting_fields as $field ) {
|
||||
if ( is_array( $field ) ) {
|
||||
$field_keys = array_keys( $field );
|
||||
$field_keys = array_keys( $field );
|
||||
$custom_sort[] = $field_keys[0];
|
||||
}
|
||||
}
|
||||
@@ -1384,7 +1401,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$this->query_args['order'] = 'ASC';
|
||||
}
|
||||
|
||||
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ) ) ) {
|
||||
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ), true ) ) {
|
||||
|
||||
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $sortby . '_c' => array(
|
||||
'key' => $sortby,
|
||||
@@ -1426,7 +1443,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$this->query_args['orderby'] = array( 'last_name_c' => 'ASC', 'first_name_c' => 'ASC' );
|
||||
unset( $this->query_args['order'] );
|
||||
|
||||
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys ) ) {
|
||||
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys, true ) ) {
|
||||
|
||||
$order = 'DESC';
|
||||
if ( strstr( $sortby, '_desc' ) ) {
|
||||
@@ -1458,18 +1475,23 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
)
|
||||
);
|
||||
|
||||
$this->query_args['orderby'] = array( $sortby . '_ns' => $order, 'user_registered' => 'DESC' );
|
||||
$this->query_args['orderby'] = array(
|
||||
$sortby . '_ns' => $order,
|
||||
'user_registered' => 'DESC',
|
||||
);
|
||||
unset( $this->query_args['order'] );
|
||||
|
||||
} elseif ( ( ! empty( $directory_data['sortby_custom'] ) && $sortby == $directory_data['sortby_custom'] ) || in_array( $sortby, $custom_sort ) ) {
|
||||
} elseif ( ( ! empty( $directory_data['sortby_custom'] ) && $sortby === $directory_data['sortby_custom'] ) || in_array( $sortby, $custom_sort, true ) ) {
|
||||
$custom_sort_order = ! empty( $directory_data['sortby_custom_order'] ) ? $directory_data['sortby_custom_order'] : 'ASC';
|
||||
|
||||
$meta_query = new \WP_Meta_Query();
|
||||
$custom_sort_type = ! empty( $directory_data['sortby_custom_type'] ) ? $meta_query->get_cast_for_type( $directory_data['sortby_custom_type'] ) : 'CHAR';
|
||||
|
||||
if ( ! empty( $directory_data['sorting_fields'] ) ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification -- already verified here
|
||||
$sorting = sanitize_text_field( $_POST['sorting'] );
|
||||
$sorting_fields = maybe_serialize( $directory_data['sorting_fields'] );
|
||||
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
|
||||
|
||||
if ( ! empty( $sorting_fields ) && is_array( $sorting_fields ) ) {
|
||||
foreach ( $sorting_fields as $field ) {
|
||||
if ( isset( $field[ $sorting ] ) ) {
|
||||
@@ -1777,6 +1799,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
* Handle filters request
|
||||
*/
|
||||
function filters( $directory_data ) {
|
||||
global $wpdb;
|
||||
//filters
|
||||
$filter_query = array();
|
||||
if ( ! empty( $directory_data['search_fields'] ) ) {
|
||||
@@ -1809,9 +1832,11 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/** This filter is documented in includes/core/class-member-directory-meta.php */
|
||||
$relation = apply_filters( 'um_members_directory_select_filter_relation', 'OR', $field );
|
||||
|
||||
switch ( $field ) {
|
||||
default:
|
||||
|
||||
$filter_type = $this->filter_types[ $field ];
|
||||
|
||||
/**
|
||||
@@ -1865,35 +1890,35 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
case 'select':
|
||||
if ( is_array( $value ) ) {
|
||||
$field_query = array( 'relation' => 'OR' );
|
||||
$field_query = array( 'relation' => esc_sql( $relation ) );
|
||||
|
||||
foreach ( $value as $single_val ) {
|
||||
$single_val = trim( stripslashes( $single_val ) );
|
||||
|
||||
$arr_meta_query = array(
|
||||
array(
|
||||
'key' => $field,
|
||||
'value' => $single_val,
|
||||
'compare' => '=',
|
||||
'key' => $field,
|
||||
'value' => $single_val,
|
||||
'compare' => '=',
|
||||
),
|
||||
array(
|
||||
'key' => $field,
|
||||
'value' => serialize( (string) $single_val ),
|
||||
'compare' => 'LIKE',
|
||||
'key' => $field,
|
||||
'value' => serialize( (string) $single_val ),
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
array(
|
||||
'key' => $field,
|
||||
'value' => '"' . $single_val . '"',
|
||||
'compare' => 'LIKE',
|
||||
)
|
||||
'key' => $field,
|
||||
'value' => '"' . $single_val . '"',
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
);
|
||||
|
||||
if ( is_numeric( $single_val ) ) {
|
||||
|
||||
$arr_meta_query[] = array(
|
||||
'key' => $field,
|
||||
'value' => serialize( (int) $single_val ),
|
||||
'compare' => 'LIKE',
|
||||
'key' => $field,
|
||||
'value' => serialize( absint( $single_val ) ),
|
||||
'compare' => 'LIKE',
|
||||
);
|
||||
|
||||
}
|
||||
@@ -1967,26 +1992,39 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
if ( ! empty( $field_query ) && $field_query !== true ) {
|
||||
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $field_query ) );
|
||||
}
|
||||
|
||||
break;
|
||||
case 'role':
|
||||
$value = array_map( 'strtolower', $value );
|
||||
|
||||
if ( ! empty( $this->query_args['role__in'] ) ) {
|
||||
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
||||
$default_role = array_intersect( $this->query_args['role__in'], $value );
|
||||
$um_role = array_diff( $value, $default_role );
|
||||
|
||||
foreach ( $um_role as $key => &$val ) {
|
||||
$val = 'um_' . str_replace( ' ', '-', $val );
|
||||
if ( 'OR' !== $relation ) {
|
||||
$role__in_clauses = array( 'relation' => $relation );
|
||||
foreach ( $value as $role ) {
|
||||
$role__in_clauses[] = array(
|
||||
'key' => $wpdb->get_blog_prefix() . 'capabilities',
|
||||
'value' => '"' . $role . '"',
|
||||
'compare' => 'LIKE',
|
||||
);
|
||||
}
|
||||
$this->query_args['role__in'] = array_merge( $default_role, $um_role );
|
||||
|
||||
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $role__in_clauses ) );
|
||||
|
||||
$this->custom_filters_in_query[ $field ] = $value;
|
||||
} else {
|
||||
$this->query_args['role__in'] = $value;
|
||||
};
|
||||
if ( ! empty( $this->query_args['role__in'] ) ) {
|
||||
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
||||
$default_role = array_intersect( $this->query_args['role__in'], $value );
|
||||
$um_role = array_diff( $value, $default_role );
|
||||
|
||||
$this->custom_filters_in_query[ $field ] = $this->query_args['role__in'];
|
||||
foreach ( $um_role as $key => &$val ) {
|
||||
$val = 'um_' . str_replace( ' ', '-', $val );
|
||||
}
|
||||
$this->query_args['role__in'] = array_merge( $default_role, $um_role );
|
||||
} else {
|
||||
$this->query_args['role__in'] = $value;
|
||||
}
|
||||
|
||||
$this->custom_filters_in_query[ $field ] = $this->query_args['role__in'];
|
||||
}
|
||||
break;
|
||||
case 'birth_date':
|
||||
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
|
||||
@@ -2008,7 +2046,6 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
break;
|
||||
case 'user_registered':
|
||||
|
||||
$offset = 0;
|
||||
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
||||
$offset = (int) $_POST['gmt_offset'];
|
||||
@@ -2044,6 +2081,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
||||
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
||||
$meta_query = array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'key' => '_um_last_login',
|
||||
'value' => array( gmdate( 'Y-m-d H:i:s', $from_date ), gmdate( 'Y-m-d H:i:s', $to_date ) ),
|
||||
@@ -2051,12 +2089,54 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
'inclusive' => true,
|
||||
'type' => 'DATETIME',
|
||||
),
|
||||
array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'um_show_last_login',
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'um_show_last_login',
|
||||
'value' => 'a:1:{i:0;s:2:"no";}',
|
||||
'compare' => '!=',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_filters_in_query[ $field ] = $value;
|
||||
|
||||
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
||||
break;
|
||||
case 'gender':
|
||||
if ( is_array( $value ) ) {
|
||||
$field_query = array( 'relation' => $relation );
|
||||
|
||||
foreach ( $value as $single_val ) {
|
||||
$single_val = trim( stripslashes( $single_val ) );
|
||||
|
||||
$arr_meta_query = array(
|
||||
array(
|
||||
'key' => $field,
|
||||
'value' => $single_val,
|
||||
'compare' => '=',
|
||||
),
|
||||
array(
|
||||
'key' => $field,
|
||||
'value' => '"' . $single_val . '"',
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
);
|
||||
|
||||
$field_query = array_merge( $field_query, $arr_meta_query );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $field_query ) ) {
|
||||
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $field_query ) );
|
||||
|
||||
$this->custom_filters_in_query[ $field ] = $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2133,35 +2213,36 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$value = array( $value );
|
||||
}
|
||||
|
||||
$field_query = array( 'relation' => 'OR' );
|
||||
/** This filter is documented in includes/core/class-member-directory.php */
|
||||
$field_query = apply_filters( 'um_members_directory_filter_select', array( 'relation' => 'OR' ), $field );
|
||||
|
||||
foreach ( $value as $single_val ) {
|
||||
$single_val = trim( $single_val );
|
||||
|
||||
$arr_meta_query = array(
|
||||
array(
|
||||
'key' => $field,
|
||||
'value' => $single_val,
|
||||
'compare' => '=',
|
||||
'key' => $field,
|
||||
'value' => $single_val,
|
||||
'compare' => '=',
|
||||
),
|
||||
array(
|
||||
'key' => $field,
|
||||
'value' => serialize( (string) $single_val ),
|
||||
'compare' => 'LIKE',
|
||||
'key' => $field,
|
||||
'value' => serialize( (string) $single_val ),
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
array(
|
||||
'key' => $field,
|
||||
'value' => '"' . $single_val . '"',
|
||||
'compare' => 'LIKE',
|
||||
)
|
||||
'key' => $field,
|
||||
'value' => '"' . $single_val . '"',
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
);
|
||||
|
||||
if ( is_numeric( $single_val ) ) {
|
||||
|
||||
$arr_meta_query[] = array(
|
||||
'key' => $field,
|
||||
'value' => serialize( (int) $single_val ),
|
||||
'compare' => 'LIKE',
|
||||
'key' => $field,
|
||||
'value' => serialize( absint( $single_val ) ),
|
||||
'compare' => 'LIKE',
|
||||
);
|
||||
|
||||
}
|
||||
@@ -2290,9 +2371,18 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$offset = $gmt_offset;
|
||||
}
|
||||
|
||||
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
||||
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
||||
$value = array_map(
|
||||
function( $date ) {
|
||||
return is_numeric( $date ) ? $date : strtotime( $date );
|
||||
},
|
||||
$value
|
||||
);
|
||||
|
||||
$from_date = gmdate( 'Y-m-d H:i:s', (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ) ); // client time zone offset
|
||||
$to_date = gmdate( 'Y-m-d H:i:s', (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1 ); // time 23:59
|
||||
|
||||
$meta_query = array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'key' => '_um_last_login',
|
||||
'value' => array( $from_date, $to_date ),
|
||||
@@ -2300,6 +2390,18 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
'inclusive' => true,
|
||||
'type' => 'DATETIME',
|
||||
),
|
||||
array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'um_show_last_login',
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'um_show_last_login',
|
||||
'value' => 'a:1:{i:0;s:2:"no";}',
|
||||
'compare' => '!=',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
||||
@@ -2385,8 +2487,8 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
if ( UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
||||
$actions['um-editprofile'] = array(
|
||||
'title' => __( 'Edit Profile', 'ultimate-member' ),
|
||||
'url' => um_edit_profile_url(),
|
||||
'title' => esc_html__( 'Edit Profile', 'ultimate-member' ),
|
||||
'url' => um_edit_profile_url(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2417,8 +2519,8 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$url = add_query_arg( array( 'um_action' => $id, 'uid' => $user_id ), um_get_core_page( 'user' ) );
|
||||
|
||||
$actions[ $id ] = array(
|
||||
'title' => $arr['label'],
|
||||
'url' => $url,
|
||||
'title' => esc_html( $arr['label'] ),
|
||||
'url' => esc_url( $url ),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2429,25 +2531,24 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
if ( empty( UM()->user()->cannot_edit ) ) {
|
||||
$actions['um-editprofile'] = array(
|
||||
'title' => __( 'Edit Profile', 'ultimate-member' ),
|
||||
'title' => esc_html__( 'Edit Profile', 'ultimate-member' ),
|
||||
'url' => um_edit_profile_url(),
|
||||
);
|
||||
}
|
||||
|
||||
$actions['um-myaccount'] = array(
|
||||
'title' => __( 'My Account', 'ultimate-member' ),
|
||||
'title' => esc_html__( 'My Account', 'ultimate-member' ),
|
||||
'url' => um_get_core_page( 'account' ),
|
||||
);
|
||||
|
||||
$actions['um-logout'] = array(
|
||||
'title' => __( 'Logout', 'ultimate-member' ),
|
||||
'title' => esc_html__( 'Logout', 'ultimate-member' ),
|
||||
'url' => um_get_core_page( 'logout' ),
|
||||
);
|
||||
|
||||
$actions = apply_filters( 'um_member_directory_my_user_card_actions', $actions, $user_id );
|
||||
}
|
||||
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
@@ -2464,7 +2565,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
$dropdown_actions = $this->build_user_actions_list( $user_id );
|
||||
|
||||
$actions = array();
|
||||
$actions = array();
|
||||
$can_edit = UM()->roles()->um_current_user_can( 'edit', $user_id );
|
||||
|
||||
// Replace hook 'um_members_just_after_name'
|
||||
@@ -2478,21 +2579,21 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
$hook_after_user_name = ob_get_clean();
|
||||
|
||||
$data_array = array(
|
||||
'card_anchor' => substr( md5( $user_id ), 10, 5 ),
|
||||
'id' => $user_id,
|
||||
'role' => um_user( 'role' ),
|
||||
'account_status' => um_user( 'account_status' ),
|
||||
'account_status_name' => um_user( 'account_status_name' ),
|
||||
'cover_photo' => um_user( 'cover_photo', $this->cover_size ),
|
||||
'display_name' => um_user( 'display_name' ),
|
||||
'profile_url' => um_user_profile_url(),
|
||||
'can_edit' => $can_edit,
|
||||
'edit_profile_url' => um_edit_profile_url(),
|
||||
'avatar' => get_avatar( $user_id, $this->avatar_size ),
|
||||
'display_name_html' => um_user( 'display_name', 'html' ),
|
||||
'dropdown_actions' => $dropdown_actions,
|
||||
'hook_just_after_name' => preg_replace( '/^\s+/im', '', $hook_just_after_name ),
|
||||
'hook_after_user_name' => preg_replace( '/^\s+/im', '', $hook_after_user_name ),
|
||||
'card_anchor' => esc_html( substr( md5( $user_id ), 10, 5 ) ),
|
||||
'id' => absint( $user_id ),
|
||||
'role' => esc_html( um_user( 'role' ) ),
|
||||
'account_status' => esc_html( um_user( 'account_status' ) ),
|
||||
'account_status_name' => esc_html( um_user( 'account_status_name' ) ),
|
||||
'cover_photo' => wp_kses( um_user( 'cover_photo', $this->cover_size ), UM()->get_allowed_html( 'templates' ) ),
|
||||
'display_name' => esc_html( um_user( 'display_name' ) ),
|
||||
'profile_url' => esc_url( um_user_profile_url() ),
|
||||
'can_edit' => (bool) $can_edit,
|
||||
'edit_profile_url' => esc_url( um_edit_profile_url() ),
|
||||
'avatar' => wp_kses( get_avatar( $user_id, $this->avatar_size ), UM()->get_allowed_html( 'templates' ) ),
|
||||
'display_name_html' => wp_kses( um_user( 'display_name', 'html' ), UM()->get_allowed_html( 'templates' ) ),
|
||||
'dropdown_actions' => $dropdown_actions,
|
||||
'hook_just_after_name' => wp_kses( preg_replace( '/^\s+/im', '', $hook_just_after_name ), UM()->get_allowed_html( 'templates' ) ),
|
||||
'hook_after_user_name' => wp_kses( preg_replace( '/^\s+/im', '', $hook_after_user_name ), UM()->get_allowed_html( 'templates' ) ),
|
||||
);
|
||||
|
||||
if ( ! empty( $directory_data['show_tagline'] ) ) {
|
||||
@@ -2506,13 +2607,20 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( '_um_last_login' === $key ) {
|
||||
$show_last_login = get_user_meta( $user_id, 'um_show_last_login', true );
|
||||
if ( ! empty( $show_last_login ) && 'no' === $show_last_login[0] ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$value = um_filtered_value( $key );
|
||||
|
||||
if ( ! $value ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data_array[ $key ] = $value;
|
||||
$data_array[ $key ] = wp_kses( $value, UM()->get_allowed_html( 'templates' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2530,6 +2638,13 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( '_um_last_login' === $key ) {
|
||||
$show_last_login = get_user_meta( $user_id, 'um_show_last_login', true );
|
||||
if ( ! empty( $show_last_login ) && 'no' === $show_last_login[0] ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$value = um_filtered_value( $key );
|
||||
if ( ! $value ) {
|
||||
continue;
|
||||
@@ -2543,8 +2658,8 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
) );
|
||||
}
|
||||
|
||||
$data_array[ "label_{$key}" ] = __( $label, 'ultimate-member' );
|
||||
$data_array[ $key ] = $value;
|
||||
$data_array[ "label_{$key}" ] = esc_html__( $label, 'ultimate-member' );
|
||||
$data_array[ $key ] = wp_kses( $value, UM()->get_allowed_html( 'templates' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2554,7 +2669,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
UM()->fields()->show_social_urls();
|
||||
$social_urls = ob_get_clean();
|
||||
|
||||
$data_array['social_urls'] = $social_urls;
|
||||
$data_array['social_urls'] = wp_kses( $social_urls, UM()->get_allowed_html( 'templates' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2643,14 +2758,13 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
// Prepare default user query values
|
||||
$this->query_args = array(
|
||||
'fields' => 'ids',
|
||||
'number' => 0,
|
||||
'meta_query' => array(
|
||||
'relation' => 'AND'
|
||||
'fields' => 'ids',
|
||||
'number' => 0,
|
||||
'meta_query' => array(
|
||||
'relation' => 'AND',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
// handle different restrictions
|
||||
$this->restriction_options();
|
||||
|
||||
@@ -2784,7 +2898,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
$this->cover_size = apply_filters( 'um_member_directory_cover_image_size', $this->cover_size, $directory_data );
|
||||
|
||||
$avatar_size = UM()->options()->get( 'profile_photosize' );
|
||||
$avatar_size = UM()->options()->get( 'profile_photosize' );
|
||||
$this->avatar_size = str_replace( 'px', '', $avatar_size );
|
||||
$this->avatar_size = apply_filters( 'um_member_directory_avatar_image_size', $this->avatar_size, $directory_data );
|
||||
|
||||
|
||||
@@ -7,64 +7,56 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
||||
if ( ! class_exists( 'um\core\Options' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Class Options
|
||||
* @package um\core
|
||||
*/
|
||||
class Options {
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
var $options = array();
|
||||
|
||||
private $options = array();
|
||||
|
||||
/**
|
||||
* Options constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
$this->init_variables();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set variables
|
||||
*/
|
||||
function init_variables() {
|
||||
private function init_variables() {
|
||||
$this->options = get_option( 'um_options', array() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get UM option value
|
||||
* Get UM option value.
|
||||
*
|
||||
* @param $option_id
|
||||
* @return mixed|string|void
|
||||
* @param string $option_id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function get( $option_id ) {
|
||||
public function get( $option_id ) {
|
||||
if ( isset( $this->options[ $option_id ] ) ) {
|
||||
/**
|
||||
* UM hook
|
||||
* Filters the plugin option.
|
||||
*
|
||||
* @type filter
|
||||
* @title um_get_option_filter__{$option_id}
|
||||
* @description Change UM option on get by $option_id
|
||||
* @input_vars
|
||||
* [{"var":"$option","type":"array","desc":"Option Value"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_get_option_filter__{$option_id}', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_get_option_filter__{$option_id}', 'my_get_option_filter', 10, 1 );
|
||||
* function my_get_option_filter( $option ) {
|
||||
* // your code here
|
||||
* return $option;
|
||||
* @param {mixed} $value Option value.
|
||||
*
|
||||
* @return {mixed} Option value.
|
||||
*
|
||||
* @since 1.3.67
|
||||
* @hook um_get_option_filter__{$option_id}
|
||||
*
|
||||
* @example <caption>Change `option_1` value.</caption>
|
||||
* function my_custom_option_1( $value ) {
|
||||
* $value = 'option_1_custom_value';
|
||||
* return $value;
|
||||
* }
|
||||
* ?>
|
||||
* add_filter( 'um_get_option_filter__option_1', 'my_custom_option_1' );
|
||||
*/
|
||||
return apply_filters( "um_get_option_filter__{$option_id}", $this->options[ $option_id ] );
|
||||
}
|
||||
@@ -72,35 +64,30 @@ if ( ! class_exists( 'um\core\Options' ) ) {
|
||||
switch ( $option_id ) {
|
||||
case 'site_name':
|
||||
return get_bloginfo( 'name' );
|
||||
break;
|
||||
case 'admin_email':
|
||||
return get_bloginfo( 'admin_email' );
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update UM option value
|
||||
*
|
||||
* @param $option_id
|
||||
* @param $value
|
||||
*/
|
||||
function update( $option_id, $value ) {
|
||||
public function update( $option_id, $value ) {
|
||||
$this->options[ $option_id ] = $value;
|
||||
update_option( 'um_options', $this->options );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete UM option
|
||||
*
|
||||
* @param $option_id
|
||||
*/
|
||||
function remove( $option_id ) {
|
||||
public function remove( $option_id ) {
|
||||
if ( ! empty( $this->options[ $option_id ] ) ) {
|
||||
unset( $this->options[ $option_id ] );
|
||||
}
|
||||
@@ -108,16 +95,15 @@ if ( ! class_exists( 'um\core\Options' ) ) {
|
||||
update_option( 'um_options', $this->options );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get UM option default value
|
||||
*
|
||||
* @use UM()->config()
|
||||
*
|
||||
* @param $option_id
|
||||
* @param string $option_id
|
||||
* @return mixed
|
||||
*/
|
||||
function get_default( $option_id ) {
|
||||
public function get_default( $option_id ) {
|
||||
$settings_defaults = UM()->config()->settings_defaults;
|
||||
if ( ! isset( $settings_defaults[ $option_id ] ) ) {
|
||||
return false;
|
||||
@@ -136,40 +122,58 @@ if ( ! class_exists( 'um\core\Options' ) ) {
|
||||
* @return string
|
||||
*/
|
||||
public function get_predefined_page_option_key( $slug ) {
|
||||
/**
|
||||
* Filters the predefined page option key.
|
||||
*
|
||||
* @param {string} $option_key Predefined page option key.
|
||||
*
|
||||
* @return {string} Predefined page option key.
|
||||
*
|
||||
* @since 2.8.3
|
||||
* @hook um_predefined_page_option_key
|
||||
*
|
||||
* @example <caption>Change option key for login predefined page.</caption>
|
||||
* function my_um_predefined_page_option_key( $option_key ) {
|
||||
* if ( 'core_login' === $option_key ) {
|
||||
* $option_key = 'core_login_custom';
|
||||
* }
|
||||
* return $option_key;
|
||||
* }
|
||||
* add_filter( 'um_predefined_page_option_key', 'my_um_predefined_page_option_key' );
|
||||
*/
|
||||
return apply_filters( 'um_predefined_page_option_key', "core_{$slug}" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get core page ID
|
||||
*
|
||||
* @todo Deprecate soon
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed|void
|
||||
* @return string
|
||||
*/
|
||||
function get_core_page_id( $key ) {
|
||||
public function get_core_page_id( $key ) {
|
||||
/**
|
||||
* UM hook
|
||||
* Filters the predefined page option key.
|
||||
*
|
||||
* @type filter
|
||||
* @title um_core_page_id_filter
|
||||
* @description Change UM page slug
|
||||
* @input_vars
|
||||
* [{"var":"$slug","type":"array","desc":"UM page slug"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_core_page_id_filter', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_core_page_id_filter', 'my_core_page_id', 10, 1 );
|
||||
* function my_core_page_id( $slug ) {
|
||||
* // your code here
|
||||
* return $slug;
|
||||
* @param {string} $page_key Predefined page option key.
|
||||
*
|
||||
* @return {string} Predefined page option key.
|
||||
*
|
||||
* @since 1.3.x
|
||||
* @hook um_core_page_id_filter
|
||||
*
|
||||
* @example <caption>Change option key for login predefined page.</caption>
|
||||
* function my_um_core_page_id_filter( $page_key ) {
|
||||
* if ( 'core_login' === $page_key ) {
|
||||
* $page_key = 'core_login_custom';
|
||||
* }
|
||||
* return $page_key;
|
||||
* }
|
||||
* ?>
|
||||
* add_filter( 'um_core_page_id_filter', 'my_um_core_page_id_filter' );
|
||||
*/
|
||||
return apply_filters( 'um_core_page_id_filter', 'core_' . $key );
|
||||
return apply_filters( 'um_core_page_id_filter', $this->get_predefined_page_option_key( $key ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,21 +38,26 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
function reset_url() {
|
||||
public function reset_url() {
|
||||
static $reset_key = null;
|
||||
|
||||
$user_id = um_user( 'ID' );
|
||||
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
|
||||
//new reset password key via WordPress native field. It maybe already exists here but generated twice to make sure that emailed with a proper and fresh hash
|
||||
// New reset password key via WordPress native field. It maybe already exists here but generated twice to make sure that emailed with a proper and fresh hash.
|
||||
// But doing that only once in 1 request using static variable. Different email placeholders can use reset_url() and we have to use 1 time generated to avoid invalid keys.
|
||||
$user_data = get_userdata( $user_id );
|
||||
$key = UM()->user()->maybe_generate_password_reset_key( $user_data );
|
||||
if ( empty( $reset_key ) ) {
|
||||
$reset_key = UM()->user()->maybe_generate_password_reset_key( $user_data );
|
||||
}
|
||||
|
||||
// this link looks like WordPress native link e.g. wp-login.php?action=rp&key={hash}&login={user_login}
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'act' => 'reset_password',
|
||||
'hash' => $key,
|
||||
'login' => $user_data->user_login,
|
||||
'hash' => $reset_key,
|
||||
'login' => rawurlencode( $user_data->user_login ),
|
||||
),
|
||||
um_get_core_page( 'password-reset' )
|
||||
);
|
||||
@@ -490,6 +495,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
|
||||
|
||||
if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) {
|
||||
UM()->form()->add_error( 'user_password', __( 'You must enter a new password', 'ultimate-member' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $args['user_password'] ) ) {
|
||||
|
||||
@@ -174,7 +174,7 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
|
||||
do_action( 'um_after_email_confirmation', $user_id );
|
||||
|
||||
if ( empty( $set_password_required ) ) {
|
||||
$redirect = empty( $user_role_data['url_email_activate'] ) ? um_get_core_page( 'login', 'account_active' ) : trim( $user_role_data['url_email_activate'] ); // Role setting "URL redirect after e-mail activation"
|
||||
$redirect = empty( $user_role_data['url_email_activate'] ) ? um_get_core_page( 'login', 'account_active' ) : trim( $user_role_data['url_email_activate'] ); // Role setting "URL redirect after email activation"
|
||||
}
|
||||
$redirect = apply_filters( 'um_after_email_confirmation_redirect', $redirect, $user_id, $login );
|
||||
|
||||
|
||||
@@ -418,6 +418,13 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
if ( ! empty( $array ) ) {
|
||||
foreach ( $array as $key ) {
|
||||
if ( $key ) {
|
||||
if ( '_um_last_login' === $key ) {
|
||||
$show_last_login = get_user_meta( um_user( 'ID' ), 'um_show_last_login', true );
|
||||
if ( ! empty( $show_last_login ) && 'no' === $show_last_login[0] ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$data = array();
|
||||
if ( isset( UM()->builtin()->all_user_fields[ $key ] ) ) {
|
||||
$data = UM()->builtin()->all_user_fields[ $key ];
|
||||
|
||||
@@ -162,6 +162,13 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) {
|
||||
if ( empty( $custom_meta ) ) {
|
||||
// Set default permalink base if custom meta is empty.
|
||||
$permalink_base = 'user_login';
|
||||
} else {
|
||||
// Ignore username slug if custom meta slug exists.
|
||||
$user_id = username_exists( um_queried_user() );
|
||||
$custom_permalink = get_user_meta( $user_id, 'um_user_profile_url_slug_' . $permalink_base, true );
|
||||
if ( ! empty( $custom_permalink ) && um_queried_user() !== $custom_permalink ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -191,27 +191,7 @@ KEY meta_value_indx (um_value(191))
|
||||
$content = '[ultimatemember form_id="' . $setup_shortcodes[ $slug ] . '"]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters Ultimate Member predefined pages content when set up the predefined page.
|
||||
*
|
||||
* @param {string} $content Predefined page content.
|
||||
* @param {string} $slug Predefined page slug (key).
|
||||
*
|
||||
* @return {string} Predefined page content.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @hook um_setup_predefined_page_content
|
||||
*
|
||||
* @example <caption>Set Ultimate Member predefined pages content with key = 'my_page_key'.</caption>
|
||||
* function my_um_setup_predefined_page_content( $content, $slug ) {
|
||||
* // your code here
|
||||
* if ( 'my_page_key' === $slug ) {
|
||||
* $content = __( 'My Page content', 'my-translate-key' );
|
||||
* }
|
||||
* return $pages;
|
||||
* }
|
||||
* add_filter( 'um_setup_predefined_page_content', 'my_um_setup_predefined_page_content' );
|
||||
*/
|
||||
/** This filter is documented in includes/core/class-setup.php */
|
||||
$content = apply_filters( 'um_setup_predefined_page_content', $content, $slug );
|
||||
|
||||
$user_page = array(
|
||||
@@ -233,7 +213,7 @@ KEY meta_value_indx (um_value(191))
|
||||
$options = get_option( 'um_options', array() );
|
||||
|
||||
foreach ( $core_pages as $slug => $page_id ) {
|
||||
$key = UM()->options()->get_core_page_id( $slug );
|
||||
$key = UM()->options()->get_predefined_page_option_key( $slug );
|
||||
$options[ $key ] = $page_id;
|
||||
}
|
||||
|
||||
@@ -243,6 +223,72 @@ KEY meta_value_indx (um_value(191))
|
||||
UM()->rewrite()->reset_rules();
|
||||
}
|
||||
|
||||
public function predefined_page( $slug, $with_rewrite = true ) {
|
||||
$page_exists = UM()->query()->find_post_id( 'page', '_um_core', $slug );
|
||||
if ( $page_exists ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$predefined_pages = UM()->config()->get( 'predefined_pages' );
|
||||
if ( empty( $predefined_pages ) || ! array_key_exists( $slug, $predefined_pages ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $predefined_pages[ $slug ];
|
||||
|
||||
if ( empty( $data['title'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = ! empty( $data['content'] ) ? $data['content'] : '';
|
||||
/**
|
||||
* Filters Ultimate Member predefined pages content when set up the predefined page.
|
||||
*
|
||||
* @param {string} $content Predefined page content.
|
||||
* @param {string} $slug Predefined page slug (key).
|
||||
*
|
||||
* @return {string} Predefined page content.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @hook um_setup_predefined_page_content
|
||||
*
|
||||
* @example <caption>Set Ultimate Member predefined pages content with key = 'my_page_key'.</caption>
|
||||
* function my_um_setup_predefined_page_content( $content, $slug ) {
|
||||
* // your code here
|
||||
* if ( 'my_page_key' === $slug ) {
|
||||
* $content = __( 'My Page content', 'my-translate-key' );
|
||||
* }
|
||||
* return $pages;
|
||||
* }
|
||||
* add_filter( 'um_setup_predefined_page_content', 'my_um_setup_predefined_page_content' );
|
||||
*/
|
||||
$content = apply_filters( 'um_setup_predefined_page_content', $content, $slug );
|
||||
|
||||
$user_page = array(
|
||||
'post_title' => $data['title'],
|
||||
'post_content' => $content,
|
||||
'post_name' => $slug,
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'publish',
|
||||
'post_author' => get_current_user_id(),
|
||||
'comment_status' => 'closed',
|
||||
);
|
||||
|
||||
$post_id = wp_insert_post( $user_page );
|
||||
if ( empty( $post_id ) || is_wp_error( $post_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_post_meta( $post_id, '_um_core', $slug );
|
||||
|
||||
UM()->options()->update( UM()->options()->get_predefined_page_option_key( $slug ), $post_id );
|
||||
|
||||
if ( $with_rewrite ) {
|
||||
// Reset rewrite rules after page creation and option upgrade.
|
||||
UM()->rewrite()->reset_rules();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default UM settings.
|
||||
*/
|
||||
|
||||
@@ -968,28 +968,29 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
/**
|
||||
* Profile photo image process
|
||||
*
|
||||
* @param array $response
|
||||
* @param array $response
|
||||
* @param string $image_path
|
||||
* @param string $src
|
||||
* @param string $key
|
||||
* @param integer $user_id
|
||||
* @param int $user_id
|
||||
* @param string $coord
|
||||
* @param array $crop
|
||||
* @param array $crop
|
||||
*
|
||||
* @since 2.0.22
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function profile_photo( $response, $image_path, $src, $key, $user_id, $coord, $crop ) {
|
||||
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
||||
|
||||
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
||||
$quality = UM()->options()->get( 'image_compression' );
|
||||
|
||||
$image = wp_get_image_editor( $image_path ); // Return an implementation that extends WP_Image_Editor
|
||||
|
||||
$temp_image_path = $image_path;
|
||||
//refresh image_path to make temporary image permanently after upload
|
||||
$image_path = pathinfo( $image_path, PATHINFO_DIRNAME ) . DIRECTORY_SEPARATOR . $key . '.' . pathinfo( $image_path, PATHINFO_EXTENSION );
|
||||
|
||||
// Refresh image_path to make temporary image permanently after upload
|
||||
$photo_ext = pathinfo( $image_path, PATHINFO_EXTENSION );
|
||||
$image_path = pathinfo( $image_path, PATHINFO_DIRNAME ) . DIRECTORY_SEPARATOR . $key . '.' . $photo_ext;
|
||||
|
||||
if ( ! is_wp_error( $image ) ) {
|
||||
$src_x = $crop[0];
|
||||
@@ -1004,12 +1005,16 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$image->resize( $max_w, $src_h );
|
||||
}
|
||||
|
||||
$image->save( $image_path );
|
||||
$save_result = $image->save( $image_path );
|
||||
|
||||
if ( is_wp_error( $save_result ) ) {
|
||||
// translators: %s is the file src.
|
||||
wp_send_json_error( sprintf( __( 'Unable to crop image file: %s', 'ultimate-member' ), $src ) );
|
||||
}
|
||||
|
||||
$image->set_quality( $quality );
|
||||
|
||||
$sizes_array = array();
|
||||
|
||||
foreach ( $sizes as $size ) {
|
||||
$sizes_array[] = array( 'width' => $size );
|
||||
}
|
||||
@@ -1020,50 +1025,49 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
|
||||
unlink( $temp_image_path );
|
||||
|
||||
$src = str_replace( '/' . $key . '_temp.', '/' . $key . '.', $src );
|
||||
$basename = $key . '_temp.' . $photo_ext;
|
||||
$src = str_replace( '/' . $basename, '/' . $save_result['file'], $src );
|
||||
|
||||
$response['image']['source_url'] = $src;
|
||||
$response['image']['source_path'] = $image_path;
|
||||
$response['image']['filename'] = wp_basename( $image_path );
|
||||
$response['image']['source_url'] = $src;
|
||||
$response['image']['source_path'] = $save_result['path'];
|
||||
$response['image']['filename'] = $save_result['file'];
|
||||
|
||||
update_user_meta( $this->user_id, $key, wp_basename( wp_basename( $image_path ) ) );
|
||||
update_user_meta( $this->user_id, $key, $save_result['file'] );
|
||||
delete_user_meta( $this->user_id, "{$key}_metadata_temp" );
|
||||
} else {
|
||||
wp_send_json_error( esc_js( __( "Unable to crop image file: {$src}", 'ultimate-member' ) ) );
|
||||
// translators: %s is the file src.
|
||||
wp_send_json_error( sprintf( __( 'Unable to crop image file: %s', 'ultimate-member' ), $src ) );
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cover photo image process
|
||||
*
|
||||
* @param string $src
|
||||
* @param integer $user_id
|
||||
* @param int $user_id
|
||||
* @param string $coord
|
||||
* @param array $crop
|
||||
* @param array $response
|
||||
* @param array $crop
|
||||
* @param array $response
|
||||
*
|
||||
* @since 2.0.22
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function cover_photo( $response, $image_path, $src, $key, $user_id, $coord, $crop ) {
|
||||
|
||||
$sizes = UM()->options()->get( 'cover_thumb_sizes' );
|
||||
|
||||
$sizes = UM()->options()->get( 'cover_thumb_sizes' );
|
||||
$quality = UM()->options()->get( 'image_compression' );
|
||||
|
||||
$image = wp_get_image_editor( $image_path ); // Return an implementation that extends WP_Image_Editor
|
||||
|
||||
$temp_image_path = $image_path;
|
||||
|
||||
//refresh image_path to make temporary image permanently after upload
|
||||
$image_path = pathinfo( $image_path, PATHINFO_DIRNAME ) . DIRECTORY_SEPARATOR . $key . '.' . pathinfo( $image_path, PATHINFO_EXTENSION );
|
||||
// Refresh image_path to make temporary image permanently after upload
|
||||
$photo_ext = pathinfo( $image_path, PATHINFO_EXTENSION );
|
||||
$image_path = pathinfo( $image_path, PATHINFO_DIRNAME ) . DIRECTORY_SEPARATOR . $key . '.' . $photo_ext;
|
||||
|
||||
if ( ! is_wp_error( $image ) ) {
|
||||
|
||||
$src_x = $crop[0];
|
||||
$src_y = $crop[1];
|
||||
$src_w = $crop[2];
|
||||
@@ -1076,7 +1080,12 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
$image->resize( $max_w, $src_h );
|
||||
}
|
||||
|
||||
$image->save( $image_path );
|
||||
$save_result = $image->save( $image_path );
|
||||
|
||||
if ( is_wp_error( $save_result ) ) {
|
||||
// translators: %s is the file src.
|
||||
wp_send_json_error( sprintf( __( 'Unable to crop image file: %s', 'ultimate-member' ), $src ) );
|
||||
}
|
||||
|
||||
$image->set_quality( $quality );
|
||||
|
||||
@@ -1090,7 +1099,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
|
||||
// change filenames of resized images
|
||||
foreach ( $resize as $row ) {
|
||||
$new_filename = str_replace( "x{$row['height']}" , '', $row['file'] );
|
||||
$new_filename = str_replace( "x{$row['height']}", '', $row['file'] );
|
||||
$old_filename = $row['file'];
|
||||
|
||||
rename( dirname( $image_path ) . DIRECTORY_SEPARATOR . $old_filename, dirname( $image_path ) . DIRECTORY_SEPARATOR . $new_filename );
|
||||
@@ -1098,16 +1107,18 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
|
||||
unlink( $temp_image_path );
|
||||
|
||||
$src = str_replace( '/' . $key . '_temp.', '/' . $key . '.', $src );
|
||||
$basename = $key . '_temp.' . $photo_ext;
|
||||
$src = str_replace( '/' . $basename, '/' . $save_result['file'], $src );
|
||||
|
||||
$response['image']['source_url'] = $src;
|
||||
$response['image']['source_path'] = $image_path;
|
||||
$response['image']['filename'] = wp_basename( $image_path );
|
||||
$response['image']['source_url'] = $src;
|
||||
$response['image']['source_path'] = $save_result['path'];
|
||||
$response['image']['filename'] = $save_result['file'];
|
||||
|
||||
update_user_meta( $this->user_id, $key, wp_basename( wp_basename( $image_path ) ) );
|
||||
update_user_meta( $this->user_id, $key, $save_result['file'] );
|
||||
delete_user_meta( $this->user_id, "{$key}_metadata_temp" );
|
||||
} else {
|
||||
wp_send_json_error( esc_js( __( "Unable to crop image file: {$src}", 'ultimate-member' ) ) );
|
||||
// translators: %s is the file src.
|
||||
wp_send_json_error( sprintf( __( 'Unable to crop image file: %s', 'ultimate-member' ), $src ) );
|
||||
}
|
||||
|
||||
return $response;
|
||||
@@ -1195,15 +1206,15 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
||||
|
||||
$response = array(
|
||||
'image' => array(
|
||||
'source_url' => $src,
|
||||
'source_path' => $image_path,
|
||||
'filename' => wp_basename( $image_path ),
|
||||
'source_url' => $src,
|
||||
'source_path' => $image_path,
|
||||
'filename' => wp_basename( $image_path ),
|
||||
),
|
||||
);
|
||||
|
||||
$response = apply_filters( "um_upload_image_process__{$key}", $response, $image_path, $src, $key, $user_id, $coord, $crop );
|
||||
|
||||
if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
||||
if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ), true ) ) {
|
||||
$response = apply_filters( 'um_upload_stream_image_process', $response, $image_path, $src, $key, $user_id, $coord, $crop );
|
||||
}
|
||||
|
||||
|
||||
@@ -1301,7 +1301,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
}
|
||||
|
||||
if ( $this->usermeta['account_status'][0] == 'awaiting_email_confirmation' ) {
|
||||
$this->usermeta['account_status_name'][0] = __( 'Awaiting E-mail Confirmation', 'ultimate-member' );
|
||||
$this->usermeta['account_status_name'][0] = __( 'Awaiting Email Confirmation', 'ultimate-member' );
|
||||
}
|
||||
|
||||
if ( $this->usermeta['account_status'][0] == 'awaiting_admin_review' ) {
|
||||
@@ -1607,7 +1607,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
$expiry_time = UM()->options()->get( 'activation_link_expiry_time' );
|
||||
if ( ! empty( $expiry_time ) && is_numeric( $expiry_time ) ) {
|
||||
$this->profile['account_secret_hash_expiry'] = time() + $expiry_time;
|
||||
$this->profile['account_secret_hash_expiry'] = time() + $expiry_time * DAY_IN_SECONDS;
|
||||
$this->update_usermeta_info( 'account_secret_hash_expiry' );
|
||||
}
|
||||
|
||||
@@ -1676,7 +1676,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* This method approves a user membership and sends them an optional welcome/approval e-mail.
|
||||
* This method approves a user membership and sends them an optional welcome/approval email.
|
||||
*
|
||||
* @usage <?php UM()->user()->approve(); ?>
|
||||
*
|
||||
@@ -1758,7 +1758,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* This method puts a user under manual review by administrator and sends them an optional e-mail.
|
||||
* This method puts a user under manual review by administrator and sends them an optional email.
|
||||
*
|
||||
* @usage <?php UM()->user()->pending(); ?>
|
||||
*
|
||||
@@ -1784,7 +1784,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* This method rejects a user membership and sends them an optional e-mail.
|
||||
* This method rejects a user membership and sends them an optional email.
|
||||
*
|
||||
* @usage <?php UM()->user()->reject(); ?>
|
||||
*
|
||||
@@ -1811,7 +1811,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* This method deactivates a user membership and sends them an optional e-mail.
|
||||
* This method deactivates a user membership and sends them an optional email.
|
||||
*
|
||||
* @usage <?php UM()->user()->deactivate(); ?>
|
||||
*
|
||||
|
||||
@@ -157,15 +157,15 @@ function um_submit_account_errors_hook( $args ) {
|
||||
if ( isset( $args['user_email'] ) ) {
|
||||
|
||||
if ( strlen( trim( $args['user_email'] ) ) === 0 ) {
|
||||
UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
|
||||
UM()->form()->add_error( 'user_email', __( 'You must provide your email', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( ! is_email( $args['user_email'] ) ) {
|
||||
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
|
||||
UM()->form()->add_error( 'user_email', __( 'Please provide a valid email', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( email_exists( $args['user_email'] ) && email_exists( $args['user_email'] ) !== get_current_user_id() ) {
|
||||
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
|
||||
UM()->form()->add_error( 'user_email', __( 'Please provide a valid email', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ function um_submit_account_details( $args ) {
|
||||
$v = sanitize_text_field( $v );
|
||||
} elseif ( 'user_email' === $k ) {
|
||||
$v = sanitize_email( $v );
|
||||
} elseif ( 'hide_in_members' === $k ) {
|
||||
} elseif ( 'hide_in_members' === $k || 'um_show_last_login' === $k ) {
|
||||
$v = array_map( 'sanitize_text_field', $v );
|
||||
}
|
||||
|
||||
@@ -351,6 +351,13 @@ function um_submit_account_details( $args ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $changes['um_show_last_login'] ) ) {
|
||||
if ( 'yes' === $changes['um_show_last_login'] || array_intersect( array( 'yes' ), $changes['um_show_last_login'] ) ) {
|
||||
delete_user_meta( $user_id, 'um_show_last_login' );
|
||||
unset( $changes['um_show_last_login'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -552,8 +559,13 @@ add_action( 'um_after_user_account_updated', 'um_after_user_account_updated_perm
|
||||
* @param $changed
|
||||
*/
|
||||
function um_account_updated_notification( $user_id, $changed ) {
|
||||
um_fetch_user( $user_id );
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'changedaccount_email' );
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
if ( 'password' !== $_POST['_um_account_tab'] || ! UM()->options()->get( 'changedpw_email_on' ) ) {
|
||||
// Avoid email duplicates (account changed and password changed) on the password change tab.
|
||||
um_fetch_user( $user_id );
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'changedaccount_email' );
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification
|
||||
}
|
||||
add_action( 'um_after_user_account_updated', 'um_account_updated_notification', 20, 2 );
|
||||
|
||||
@@ -612,7 +624,7 @@ function um_after_account_privacy( $args ) {
|
||||
$exports_url = wp_privacy_exports_url();
|
||||
|
||||
echo '<p>' . esc_html__( 'You could download your previous data:', 'ultimate-member' ) . '</p>';
|
||||
echo '<a href="' . esc_attr( $exports_url . get_post_meta( $completed['ID'], '_export_file_name', true ) ) . '">' . esc_html__( 'Download Personal Data', 'ultimate-member' ) . '</a>';
|
||||
echo '<a href="' . esc_url( $exports_url . get_post_meta( $completed['ID'], '_export_file_name', true ) ) . '">' . esc_html__( 'Download Personal Data', 'ultimate-member' ) . '</a>';
|
||||
echo '<p>' . esc_html__( 'You could send a new request for an export of personal your data.', 'ultimate-member' ) . '</p>';
|
||||
|
||||
}
|
||||
|
||||
@@ -821,7 +821,7 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
case 'soundcloud_url':
|
||||
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'soundcloud.com' ) ) {
|
||||
// translators: %s: label.
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL','ultimate-member'), $array['label'] ) );
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -840,7 +840,6 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
break;
|
||||
|
||||
case 'instagram_url':
|
||||
|
||||
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'instagram.com' ) ) {
|
||||
// translators: %s: label.
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
|
||||
@@ -861,7 +860,6 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
break;
|
||||
|
||||
case 'tiktok_url':
|
||||
|
||||
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'tiktok.com' ) ) {
|
||||
// translators: %s: label.
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
|
||||
@@ -869,7 +867,6 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
break;
|
||||
|
||||
case 'twitch_url':
|
||||
|
||||
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'twitch.tv' ) ) {
|
||||
// translators: %s: label.
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
|
||||
@@ -877,7 +874,6 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
break;
|
||||
|
||||
case 'reddit_url':
|
||||
|
||||
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'reddit.com' ) ) {
|
||||
// translators: %s: label.
|
||||
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
|
||||
@@ -891,126 +887,126 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
break;
|
||||
|
||||
case 'unique_username':
|
||||
|
||||
if ( $submitted_data[ $key ] == '' ) {
|
||||
if ( '' === $submitted_data[ $key ] ) {
|
||||
UM()->form()->add_error( $key, __( 'You must provide a username', 'ultimate-member' ) );
|
||||
} elseif ( $mode == 'register' && username_exists( sanitize_user( $submitted_data[ $key ] ) ) ) {
|
||||
} elseif ( 'register' === $mode && username_exists( sanitize_user( $submitted_data[ $key ] ) ) ) {
|
||||
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
|
||||
} elseif ( is_email( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'Username cannot be an email', 'ultimate-member' ) );
|
||||
} elseif ( ! UM()->validation()->safe_username( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'unique_username_or_email':
|
||||
|
||||
if ( $submitted_data[ $key ] == '' ) {
|
||||
if ( '' === $submitted_data[ $key ] ) {
|
||||
UM()->form()->add_error( $key, __( 'You must provide a username or email', 'ultimate-member' ) );
|
||||
} elseif ( $mode == 'register' && username_exists( sanitize_user( $submitted_data[ $key ] ) ) ) {
|
||||
} elseif ( 'register' === $mode && username_exists( sanitize_user( $submitted_data[ $key ] ) ) ) {
|
||||
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
|
||||
} elseif ( $mode == 'register' && email_exists( $submitted_data[ $key ] ) ) {
|
||||
} elseif ( 'register' === $mode && email_exists( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
||||
} elseif ( ! UM()->validation()->safe_username( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'unique_email':
|
||||
|
||||
$submitted_data[ $key ] = trim( $submitted_data[ $key ] );
|
||||
|
||||
if ( in_array( $key, array( 'user_email' ) ) ) {
|
||||
|
||||
if ( ! isset( $submitted_data['user_id'] ) ){
|
||||
if ( 'user_email' === $key ) {
|
||||
if ( ! isset( $submitted_data['user_id'] ) ) {
|
||||
$submitted_data['user_id'] = um_get_requested_user();
|
||||
}
|
||||
|
||||
$email_exists = email_exists( $submitted_data[ $key ] );
|
||||
|
||||
if ( $submitted_data[ $key ] == '' && in_array( $key, array( 'user_email' ) ) ) {
|
||||
if ( '' === $submitted_data[ $key ] ) {
|
||||
UM()->form()->add_error( $key, __( 'You must provide your email', 'ultimate-member' ) );
|
||||
} elseif ( in_array( $mode, array( 'register' ) ) && $email_exists ) {
|
||||
} elseif ( 'register' === $mode && $email_exists ) {
|
||||
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
||||
} elseif ( in_array( $mode, array( 'profile' ) ) && $email_exists && $email_exists != $submitted_data['user_id'] ) {
|
||||
} elseif ( 'profile' === $mode && $email_exists && $email_exists !== $submitted_data['user_id'] ) {
|
||||
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
||||
} elseif ( ! is_email( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member') );
|
||||
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
||||
} elseif ( ! UM()->validation()->safe_username( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'Your email contains invalid characters', 'ultimate-member' ) );
|
||||
UM()->form()->add_error( $key, __( 'Your email contains invalid characters', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ( $submitted_data[ $key ] != '' && ! is_email( $submitted_data[ $key ] ) ) {
|
||||
if ( '' !== $submitted_data[ $key ] && ! is_email( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
||||
} elseif ( $submitted_data[ $key ] != '' && email_exists( $submitted_data[ $key ] ) ) {
|
||||
} elseif ( '' !== $submitted_data[ $key ] && email_exists( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
||||
} elseif ( $submitted_data[ $key ] != '' ) {
|
||||
} elseif ( '' !== $submitted_data[ $key ] ) {
|
||||
|
||||
$users = get_users( 'meta_value=' . $submitted_data[ $key ] );
|
||||
|
||||
foreach ( $users as $user ) {
|
||||
if ( $user->ID != $submitted_data['user_id'] ) {
|
||||
if ( $user->ID !== $submitted_data['user_id'] ) {
|
||||
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'is_email':
|
||||
|
||||
$submitted_data[ $key ] = trim( $submitted_data[ $key ] );
|
||||
|
||||
if ( $submitted_data[ $key ] != '' && ! is_email( $submitted_data[ $key ] ) ) {
|
||||
if ( '' !== $submitted_data[ $key ] && ! is_email( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'This is not a valid email', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'unique_value':
|
||||
if ( '' !== $submitted_data[ $key ] ) {
|
||||
|
||||
if ( $submitted_data[ $key ] != '' ) {
|
||||
if ( ! isset( $submitted_data['user_id'] ) ) {
|
||||
$submitted_data['user_id'] = um_get_requested_user();
|
||||
}
|
||||
|
||||
$args_unique_meta = array(
|
||||
'meta_key' => $key,
|
||||
'meta_value' => $submitted_data[ $key ],
|
||||
'compare' => '=',
|
||||
'exclude' => array( $submitted_data['user_id'] ),
|
||||
'meta_key' => $key,
|
||||
'meta_value' => $submitted_data[ $key ],
|
||||
'compare' => '=',
|
||||
'exclude' => array( $submitted_data['user_id'] ),
|
||||
);
|
||||
|
||||
$meta_key_exists = get_users( $args_unique_meta );
|
||||
|
||||
if ( $meta_key_exists ) {
|
||||
UM()->form()->add_error( $key , __( 'You must provide a unique value', 'ultimate-member' ) );
|
||||
UM()->form()->add_error( $key, __( 'You must provide a unique value', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'alphabetic':
|
||||
|
||||
if ( $submitted_data[ $key ] != '' ) {
|
||||
|
||||
if ( '' !== $submitted_data[ $key ] ) {
|
||||
if ( ! preg_match( '/^\p{L}+$/u', str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {
|
||||
UM()->form()->add_error( $key, __( 'You must provide alphabetic letters', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'alpha_numeric':
|
||||
if ( '' !== $submitted_data[ $key ] ) {
|
||||
if ( ! preg_match( '/^[\p{L}0-9\s]+$/u', str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {
|
||||
UM()->form()->add_error( $key, __( 'You must provide alphabetic letters or numbers', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'lowercase':
|
||||
if ( '' !== $submitted_data[ $key ] ) {
|
||||
if ( ! ctype_lower( str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {
|
||||
UM()->form()->add_error( $key, __( 'You must provide lowercase letters.', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
if ( $submitted_data[ $key ] != '' ) {
|
||||
|
||||
if ( ! ctype_lower( str_replace(' ', '', $submitted_data[ $key ] ) ) ) {
|
||||
UM()->form()->add_error( $key , __( 'You must provide lowercase letters.', 'ultimate-member' ) );
|
||||
case 'english':
|
||||
if ( '' !== $submitted_data[ $key ] ) {
|
||||
if ( ! preg_match( '/^[a-zA-Z]*$/u', str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {
|
||||
UM()->form()->add_error( $key, __( 'You must provide English letters.', 'ultimate-member' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1076,9 +1072,12 @@ add_action( 'um_submit_form_errors_hook_', 'um_submit_form_errors_hook_', 10, 2
|
||||
* @return string
|
||||
*/
|
||||
function um_invalid_nonce_redirect_url( $url ) {
|
||||
$url = add_query_arg( [
|
||||
'um-hash' => substr( md5( rand() ), 0, 6 ),
|
||||
], remove_query_arg( 'um-hash', $url ) );
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'um-hash' => substr( md5( rand() ), 0, 6 ),
|
||||
),
|
||||
remove_query_arg( 'um-hash', $url )
|
||||
);
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ function um_add_update_notice( $args ) {
|
||||
$err = __( 'Your account has not been approved yet.', 'ultimate-member' );
|
||||
break;
|
||||
case 'awaiting_email_confirmation':
|
||||
$err = __( 'Your account is awaiting e-mail verification.', 'ultimate-member' );
|
||||
$err = __( 'Your account is awaiting email verification.', 'ultimate-member' );
|
||||
break;
|
||||
case 'rejected':
|
||||
$err = __( 'Your membership request has been rejected.', 'ultimate-member' );
|
||||
|
||||
@@ -1017,7 +1017,7 @@ function um_profile_header( $args ) {
|
||||
*/
|
||||
do_action( 'um_pre_header_editprofile', $args ); ?>
|
||||
|
||||
<div class="um-profile-photo" data-user_id="<?php echo esc_attr( um_profile_id() ); ?>" <?php echo esc_html( UM()->fields()->aria_valid_attributes( UM()->fields()->is_error( 'profile_photo' ), 'profile_photo' ) ); ?>>
|
||||
<div class="um-profile-photo" data-user_id="<?php echo esc_attr( um_profile_id() ); ?>" <?php echo wp_kses( UM()->fields()->aria_valid_attributes( UM()->fields()->is_error( 'profile_photo' ), 'profile_photo' ), UM()->get_allowed_html( 'templates' ) ); ?>>
|
||||
|
||||
<a href="<?php echo esc_url( um_user_profile_url() ); ?>" class="um-profile-photo-img" title="<?php echo esc_attr( um_user( 'display_name' ) ); ?>">
|
||||
<?php if ( ! $default_size || $default_size == 'original' ) {
|
||||
@@ -1278,7 +1278,7 @@ function um_profile_header( $args ) {
|
||||
<textarea id="um-meta-bio" data-html="<?php echo esc_attr( $bio_html ); ?>"
|
||||
data-character-limit="<?php echo esc_attr( $limit ); ?>"
|
||||
placeholder="<?php esc_attr_e( 'Tell us a bit about yourself...', 'ultimate-member' ); ?>"
|
||||
name="<?php echo esc_attr( $description_key ); ?>" <?php echo esc_html( UM()->fields()->aria_valid_attributes( UM()->fields()->is_error( $description_key ), 'um-meta-bio' ) ); ?>><?php echo esc_textarea( $description_value ); ?></textarea>
|
||||
name="<?php echo esc_attr( $description_key ); ?>" <?php echo wp_kses( UM()->fields()->aria_valid_attributes( UM()->fields()->is_error( $description_key ), 'um-meta-bio' ), UM()->get_allowed_html( 'templates' ) ); ?>><?php echo esc_textarea( $description_value ); ?></textarea>
|
||||
<span class="um-meta-bio-character um-right">
|
||||
<span class="um-bio-limit"><?php echo esc_html( $limit ); ?></span>
|
||||
</span>
|
||||
@@ -1576,7 +1576,8 @@ function um_submit_form_profile( $args, $form_data ) {
|
||||
* function my_user_edit_profile( $post, $form_data ) {
|
||||
* // your code here
|
||||
* }
|
||||
* add_action( 'um_user_edit_profile', 'my_user_edit_profile', 10, 2 );
|
||||
* // Don't use priority >= 10 because there is native Ultimate Member handler on it.
|
||||
* add_action( 'um_user_edit_profile', 'my_user_edit_profile', 9, 2 );
|
||||
*/
|
||||
do_action( 'um_user_edit_profile', $args, $form_data );
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_
|
||||
* Redirect from default registration to UM registration page
|
||||
*/
|
||||
function um_form_register_redirect() {
|
||||
$page_id = UM()->options()->get( UM()->options()->get_core_page_id( 'register' ) );
|
||||
$page_id = UM()->options()->get( UM()->options()->get_predefined_page_option_key( 'register' ) );
|
||||
// Do not redirect if the registration page is not published.
|
||||
if ( ! empty( $page_id ) && 'publish' === get_post_status( $page_id ) ) {
|
||||
// Not `um_safe_redirect()` because predefined register page is situated on the same host.
|
||||
|
||||
@@ -1,37 +1,38 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Control comment author display
|
||||
* Control comment author display.
|
||||
*
|
||||
* @param $return
|
||||
* @param $author
|
||||
* @param $comment_ID
|
||||
* @param string $return The HTML-formatted comment author link.
|
||||
* @param string $author The comment author's username.
|
||||
* @param string $comment_id The comment ID as a numeric string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function um_comment_link_to_profile( $return, $author, $comment_ID ) {
|
||||
function um_comment_link_to_profile( $return, $author, $comment_id ) {
|
||||
$comment = get_comment( $comment_id );
|
||||
|
||||
$comment = get_comment( $comment_ID );
|
||||
|
||||
if( isset( $comment->user_id ) && ! empty( $comment->user_id ) ){
|
||||
if ( ! empty( $comment->user_id ) ) {
|
||||
if ( isset( UM()->user()->cached_user[ $comment->user_id ] ) && UM()->user()->cached_user[ $comment->user_id ] ) {
|
||||
|
||||
$return = '<a href="'. UM()->user()->cached_user[$comment->user_id]['url'] . '">' . UM()->user()->cached_user[$comment->user_id]['name'] . '</a>';
|
||||
|
||||
$return = '<a href="' . esc_url( UM()->user()->cached_user[ $comment->user_id ]['url'] ) . '">' . UM()->user()->cached_user[ $comment->user_id ]['name'] . '</a>';
|
||||
} else {
|
||||
|
||||
um_fetch_user( $comment->user_id );
|
||||
|
||||
UM()->user()->cached_user[ $comment->user_id ] = array('url' => um_user_profile_url(), 'name' => um_user('display_name') );
|
||||
$return = '<a href="'. UM()->user()->cached_user[$comment->user_id]['url'] . '">' . UM()->user()->cached_user[$comment->user_id]['name'] . '</a>';
|
||||
UM()->user()->cached_user[ $comment->user_id ] = array(
|
||||
'url' => um_user_profile_url(),
|
||||
'name' => um_user( 'display_name' ),
|
||||
);
|
||||
|
||||
$return = '<a href="' . esc_url( UM()->user()->cached_user[ $comment->user_id ]['url'] ) . '">' . UM()->user()->cached_user[ $comment->user_id ]['name'] . '</a>';
|
||||
|
||||
um_reset_user();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
add_filter('get_comment_author_link', 'um_comment_link_to_profile', 10000, 3 );
|
||||
add_filter( 'get_comment_author_link', 'um_comment_link_to_profile', 10000, 3 );
|
||||
|
||||
@@ -3,24 +3,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field is required?
|
||||
*
|
||||
* @param $label
|
||||
* @param $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function um_edit_label_all_fields( $label, $data ) {
|
||||
$asterisk = UM()->options()->get( 'form_asterisk' );
|
||||
if ( $asterisk && ! empty( $data['required'] ) ) {
|
||||
$label .= '<span class="um-req" title="' . esc_attr__( 'Required', 'ultimate-member' ) . '">*</span>';
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
add_filter( 'um_edit_label_all_fields', 'um_edit_label_all_fields', 10, 2 );
|
||||
|
||||
/**
|
||||
* Outputs a oEmbed field
|
||||
*
|
||||
@@ -114,7 +96,7 @@ add_filter( 'um_profile_field_filter_hook__youtube_video', 'um_profile_field_fil
|
||||
function um_profile_field_filter_hook__spotify( $value, $data ) {
|
||||
if ( preg_match( '/https:\/\/open.spotify.com\/.*/', $value ) ) {
|
||||
if ( false !== strpos( $value, '/user/' ) ) {
|
||||
$value = '<a href="' . esc_attr( $value ) . '" target="_blank">' . esc_html( $value ) . '</a>';
|
||||
$value = '<a href="' . esc_url( $value ) . '" target="_blank">' . esc_html( $value ) . '</a>';
|
||||
} else {
|
||||
$url = str_replace( 'open.spotify.com/', 'open.spotify.com/embed/', $value );
|
||||
|
||||
@@ -162,12 +144,10 @@ add_filter( 'um_profile_field_filter_hook__vimeo_video', 'um_profile_field_filte
|
||||
* @return int|string
|
||||
*/
|
||||
function um_profile_field_filter_hook__phone( $value, $data ) {
|
||||
$value = '<a href="tel:' . esc_attr( $value ) . '" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
||||
$value = '<a href="' . esc_url( 'tel:' . $value ) . '" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'um_profile_field_filter_hook__phone_number', 'um_profile_field_filter_hook__phone', 99, 2 );
|
||||
add_filter( 'um_profile_field_filter_hook__mobile_number', 'um_profile_field_filter_hook__phone', 99, 2 );
|
||||
|
||||
add_filter( 'um_profile_field_filter_hook__tel', 'um_profile_field_filter_hook__phone', 99, 2 );
|
||||
|
||||
/**
|
||||
* Outputs a viber link
|
||||
@@ -178,8 +158,9 @@ add_filter( 'um_profile_field_filter_hook__mobile_number', 'um_profile_field_fil
|
||||
* @return int|string
|
||||
*/
|
||||
function um_profile_field_filter_hook__viber( $value, $data ) {
|
||||
$value = str_replace('+', '', $value);
|
||||
$value = '<a href="viber://chat?number=%2B' . esc_attr( $value ) . '" target="_blank" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
||||
$value = str_replace( '+', '', $value );
|
||||
$url = 'viber://chat?number=%2B' . $value;
|
||||
$value = '<a href="' . esc_url( $url, array( 'viber' ) ) . '" target="_blank" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'um_profile_field_filter_hook__viber', 'um_profile_field_filter_hook__viber', 99, 2 );
|
||||
@@ -194,8 +175,9 @@ add_filter( 'um_profile_field_filter_hook__viber', 'um_profile_field_filter_hook
|
||||
* @return int|string
|
||||
*/
|
||||
function um_profile_field_filter_hook__whatsapp( $value, $data ) {
|
||||
$value = str_replace('+', '', $value);
|
||||
$value = '<a href="https://api.whatsapp.com/send?phone=' . esc_attr( $value ) . '" target="_blank" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
||||
$value = str_replace( '+', '', $value );
|
||||
$url = add_query_arg( array( 'phone' => $value ), 'https://api.whatsapp.com/send' );
|
||||
$value = '<a href="' . esc_url( $url ) . '" target="_blank" rel="nofollow" title="' . esc_attr( $data['title'] ) . '">' . esc_html( $value ) . '</a>';
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'um_profile_field_filter_hook__whatsapp', 'um_profile_field_filter_hook__whatsapp', 99, 2 );
|
||||
@@ -391,7 +373,7 @@ function um_profile_field_filter_hook__file( $value, $data ) {
|
||||
}
|
||||
$value = '<div class="um-single-file-preview show">
|
||||
<div class="um-single-fileinfo">
|
||||
<a href="' . esc_attr( $uri ) . '" target="_blank">
|
||||
<a href="' . esc_url( $uri ) . '" target="_blank">
|
||||
<span class="icon" style="background:'. UM()->files()->get_fonticon_bg_by_ext( $file_type['ext'] ) . '"><i class="'. UM()->files()->get_fonticon_by_ext( $file_type['ext'] ) .'"></i></span>
|
||||
<span class="filename">' . esc_attr( $value ) . '</span>
|
||||
</a>
|
||||
@@ -465,11 +447,13 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
||||
$url_rel = ( isset( $data['url_rel'] ) && 'nofollow' === $data['url_rel'] ) ? 'rel="nofollow"' : '';
|
||||
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
|
||||
|
||||
$protocols = wp_allowed_protocols();
|
||||
if ( false === strstr( $value, 'join.skype.com' ) ) {
|
||||
$value = 'skype:' . $value . '?chat';
|
||||
$protocols[] = 'skype';
|
||||
}
|
||||
|
||||
$value = '<a href="' . esc_attr( $value ) . '" title="' . esc_attr( $alt ) . '" target="' . esc_attr( $data['url_target'] ) . '" ' . $url_rel . '>' . esc_html( $alt ) . '</a>';
|
||||
$value = '<a href="' . esc_url( $value, $protocols ) . '" title="' . esc_attr( $alt ) . '" target="' . esc_attr( $data['url_target'] ) . '" ' . $url_rel . '>' . esc_html( $alt ) . '</a>';
|
||||
} else {
|
||||
// check $value is oEmbed
|
||||
if ( 'oembed' === $data['type'] ) {
|
||||
@@ -545,7 +529,7 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
||||
|
||||
if ( ! is_array( $value ) ) {
|
||||
if ( is_email( $value ) ) {
|
||||
$value = '<a href="mailto:' . $value . '" title="' . $value . '">' . $value . '</a>';
|
||||
$value = '<a href="' . esc_url( 'mailto:' . $value ) . '" title="' . $value . '">' . $value . '</a>';
|
||||
}
|
||||
} else {
|
||||
$value = implode( ', ', $value );
|
||||
|
||||
@@ -53,45 +53,46 @@ function um_wp_form_errors_hook_ip_test( $user, $username, $password ) {
|
||||
}
|
||||
add_filter( 'authenticate', 'um_wp_form_errors_hook_ip_test', 10, 3 );
|
||||
|
||||
|
||||
/**
|
||||
* Login checks through the WordPress admin login.
|
||||
*
|
||||
* @param $user
|
||||
* @param $username
|
||||
* @param $password
|
||||
* @param WP_Error|WP_User $user
|
||||
*
|
||||
* @return WP_Error|WP_User
|
||||
*/
|
||||
function um_wp_form_errors_hook_logincheck( $user, $username, $password ) {
|
||||
function um_wp_form_errors_hook_logincheck( $user ) {
|
||||
if ( is_wp_error( $user ) ) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
if ( isset( $user->ID ) ) {
|
||||
|
||||
um_fetch_user( $user->ID );
|
||||
$status = um_user( 'account_status' );
|
||||
|
||||
switch( $status ) {
|
||||
$error = null;
|
||||
switch ( $status ) {
|
||||
case 'inactive':
|
||||
return new WP_Error( $status, __( 'Your account has been disabled.', 'ultimate-member' ) );
|
||||
$error = new WP_Error( $status, __( 'Your account has been disabled.', 'ultimate-member' ) );
|
||||
break;
|
||||
case 'awaiting_admin_review':
|
||||
return new WP_Error( $status, __( 'Your account has not been approved yet.', 'ultimate-member' ) );
|
||||
$error = new WP_Error( $status, __( 'Your account has not been approved yet.', 'ultimate-member' ) );
|
||||
break;
|
||||
case 'awaiting_email_confirmation':
|
||||
return new WP_Error( $status, __( 'Your account is awaiting e-mail verification.', 'ultimate-member' ) );
|
||||
$error = new WP_Error( $status, __( 'Your account is awaiting email verification.', 'ultimate-member' ) );
|
||||
break;
|
||||
case 'rejected':
|
||||
return new WP_Error( $status, __( 'Your membership request has been rejected.', 'ultimate-member' ) );
|
||||
$error = new WP_Error( $status, __( 'Your membership request has been rejected.', 'ultimate-member' ) );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( null !== $error ) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
||||
return $user;
|
||||
|
||||
}
|
||||
add_filter( 'authenticate', 'um_wp_form_errors_hook_logincheck', 50, 3 );
|
||||
|
||||
add_filter( 'authenticate', 'um_wp_form_errors_hook_logincheck', 50 );
|
||||
|
||||
/**
|
||||
* Change lost password url in UM Login form
|
||||
|
||||
@@ -34,7 +34,7 @@ function um_admin_user_actions_hook( $actions, $user_id ) {
|
||||
}
|
||||
|
||||
if ( 'awaiting_email_confirmation' === $account_status ) {
|
||||
$actions['um_resend_activation'] = array( 'label' => __( 'Resend Activation E-mail', 'ultimate-member' ) );
|
||||
$actions['um_resend_activation'] = array( 'label' => __( 'Resend Activation Email', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( 'inactive' !== $account_status ) {
|
||||
|
||||
Reference in New Issue
Block a user