mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
User Meta in Profile
This commit is contained in:
@@ -11,6 +11,18 @@
|
||||
|
||||
<div class="profile-customize">
|
||||
|
||||
<p><label for="_um_profile_role"><?php _e('Make this profile role-specific','ultimatemember'); ?></label>
|
||||
<select name="_um_profile_role" id="_um_profile_role" class="umaf-selectjs" style="width: 100%">
|
||||
|
||||
<?php foreach($ultimatemember->query->get_roles( $add_default = 'All roles' ) as $key => $value) { ?>
|
||||
|
||||
<option value="<?php echo $key; ?>" <?php selected($key, $ultimatemember->query->get_meta_value('_um_profile_role', null, um_get_option('profile_role') ) ); ?>><?php echo $value; ?></option>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p><label for="_um_profile_template"><?php _e('Template','ultimatemember'); ?></label>
|
||||
<select name="_um_profile_template" id="_um_profile_template" class="umaf-selectjs" style="width: 100%">
|
||||
|
||||
@@ -148,6 +160,24 @@
|
||||
<input type="text" value="<?php echo $ultimatemember->query->get_meta_value('_um_profile_header_icon_hcolor', null, um_get_option('profile_header_icon_hcolor') ); ?>" class="um-admin-colorpicker" name="_um_profile_header_icon_hcolor" id="_um_profile_header_icon_hcolor" data-default-color="<?php echo um_get_option('profile_header_icon_hcolor'); ?>" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><?php _e('Show display name in profile header?','ultimatemember'); ?></label>
|
||||
<span>
|
||||
|
||||
<?php $this->ui_on_off('_um_profile_show_name', 1 ); ?>
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
<p>
|
||||
<label><?php _e('Show user description in profile header?','ultimatemember'); ?></label>
|
||||
<span>
|
||||
|
||||
<?php $this->ui_on_off('_um_profile_show_bio', 1 ); ?>
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
<span class="um-admin-field">
|
||||
|
||||
<select name="_um_profile_metafields[]" id="_um_profile_metafields" class="umaf-selectjs" style="width: 180px" data-placeholder="Choose a field">
|
||||
<?php foreach($ultimatemember->builtin->all_user_fields() as $key => $arr) { ?>
|
||||
<select name="_um_profile_metafields[]" id="_um_profile_metafields" class="umaf-selectjs" style="width: 200px" data-placeholder="Choose a field">
|
||||
<?php foreach($ultimatemember->builtin->all_user_fields( array('textarea') ) as $key => $arr) { ?>
|
||||
<option value="<?php echo $key; ?>" <?php selected($key, $val ); ?>><?php echo isset( $arr['title'] ) ? $arr['title'] : ''; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
@@ -34,8 +34,8 @@
|
||||
|
||||
<span class="um-admin-field">
|
||||
|
||||
<select name="_um_profile_metafields[]" id="_um_profile_metafields" class="umaf-selectjs" style="width: 180px" data-placeholder="Choose a field">
|
||||
<?php foreach($ultimatemember->builtin->all_user_fields() as $key => $arr) { ?>
|
||||
<select name="_um_profile_metafields[]" id="_um_profile_metafields" class="umaf-selectjs" style="width: 200px" data-placeholder="Choose a field">
|
||||
<?php foreach($ultimatemember->builtin->all_user_fields( array('textarea') ) as $key => $arr) { ?>
|
||||
<option value="<?php echo $key; ?>" <?php selected($key, $ultimatemember->query->get_meta_value('_um_profile_metafields', $key) ); ?>><?php echo isset( $arr['title'] ) ? $arr['title'] : ''; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
@@ -48,13 +48,4 @@
|
||||
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
<p>
|
||||
<label><?php _e('Show user description in profile header? ','ultimatemember'); ?></label>
|
||||
<span>
|
||||
|
||||
<?php $this->ui_on_off('_um_profile_show_bio', 1 ); ?>
|
||||
|
||||
</span>
|
||||
</p><div class="um-admin-clear"></div>
|
||||
|
||||
</div>
|
||||
@@ -200,7 +200,7 @@ print "
|
||||
.um-$form_id.um .um-form input[type=password],
|
||||
.um-$form_id.um .um-form textarea
|
||||
{
|
||||
color: $form_text_color !important;
|
||||
color: $form_text_color;
|
||||
}
|
||||
|
||||
.um-$form_id.um .um-form input:-webkit-autofill {
|
||||
|
||||
@@ -172,7 +172,9 @@
|
||||
<div class="um-profile-meta">
|
||||
|
||||
<div class="um-main-meta">
|
||||
<?php if ( $args['show_name'] ) { ?>
|
||||
<div class="um-name"><a href="<?php echo um_user_profile_url(); ?>"><?php echo um_user('display_name'); ?></a></div>
|
||||
<?php } ?>
|
||||
<div class="um-clear"></div>
|
||||
</div>
|
||||
|
||||
@@ -275,6 +277,11 @@
|
||||
do_action('um_user_before_updating_profile', $userinfo );
|
||||
|
||||
foreach( $fields as $key => $array ) {
|
||||
|
||||
if ( $fields[$key]['type'] == 'multiselect' || $fields[$key]['type'] == 'checkbox' && !isset($args['submitted'][$key]) ) {
|
||||
delete_user_meta( um_user('ID'), $key );
|
||||
}
|
||||
|
||||
if ( isset( $args['submitted'][ $key ] ) ) {
|
||||
|
||||
if ( isset( $userinfo[$key]) && $args['submitted'][$key] != $userinfo[$key] ) {
|
||||
@@ -285,7 +292,7 @@
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( is_array( $to_update ) ) {
|
||||
$ultimatemember->user->update_profile( $to_update );
|
||||
}
|
||||
|
||||
+32
-3
@@ -29,8 +29,25 @@ class UM_Builtin {
|
||||
***/
|
||||
function get_specific_fields( $fields ) {
|
||||
$fields = explode(',', $fields);
|
||||
$array=array();
|
||||
foreach ($fields as $field ) {
|
||||
$array[$field] = $this->predefined_fields[$field];
|
||||
if ( isset( $this->predefined_fields[$field] ) ) {
|
||||
$array[$field] = $this->predefined_fields[$field];
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @get specific field
|
||||
***/
|
||||
function get_specific_field( $fields ) {
|
||||
$fields = explode(',', $fields);
|
||||
$array=array();
|
||||
foreach ($fields as $field ) {
|
||||
if ( isset( $this->predefined_fields[$field] ) ) {
|
||||
$array = $this->predefined_fields[$field];
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
@@ -594,6 +611,7 @@ class UM_Builtin {
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-icon-facebook-alt',
|
||||
'validate' => 'facebook_url',
|
||||
'url_text' => 'Facebook',
|
||||
),
|
||||
|
||||
'twitter' => array(
|
||||
@@ -608,6 +626,7 @@ class UM_Builtin {
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-icon-twitter',
|
||||
'validate' => 'twitter_url',
|
||||
'url_text' => 'Twitter',
|
||||
),
|
||||
|
||||
'linkedin' => array(
|
||||
@@ -622,6 +641,7 @@ class UM_Builtin {
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-icon-linkedin-alt-1',
|
||||
'validate' => 'linkedin_url',
|
||||
'url_text' => 'LinkedIn',
|
||||
),
|
||||
|
||||
'googleplus' => array(
|
||||
@@ -636,6 +656,7 @@ class UM_Builtin {
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-icon-google-plus',
|
||||
'validate' => 'google_url',
|
||||
'url_text' => 'Google+',
|
||||
),
|
||||
|
||||
'instagram' => array(
|
||||
@@ -650,6 +671,7 @@ class UM_Builtin {
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-icon-instagrem',
|
||||
'validate' => 'instagram_url',
|
||||
'url_text' => 'Instagram',
|
||||
),
|
||||
|
||||
'skype' => array(
|
||||
@@ -664,6 +686,7 @@ class UM_Builtin {
|
||||
'url_rel' => 'nofollow',
|
||||
'icon' => 'um-icon-skype',
|
||||
'validate' => 'skype',
|
||||
'url_text' => 'Skype',
|
||||
),
|
||||
|
||||
'role_select' => array(
|
||||
@@ -836,7 +859,7 @@ class UM_Builtin {
|
||||
/***
|
||||
*** @predefined + custom fields ( Global, not form wide )
|
||||
***/
|
||||
function all_user_fields() {
|
||||
function all_user_fields( $exclude_types = array() ) {
|
||||
|
||||
global $ultimatemember;
|
||||
|
||||
@@ -852,7 +875,13 @@ class UM_Builtin {
|
||||
}
|
||||
|
||||
foreach( $all as $k => $arr ) {
|
||||
if ( isset( $arr['account_only'] ) ) {
|
||||
if ( $exclude_types && in_array( $arr['type'], $exclude_types ) ) {
|
||||
unset( $all[$k] );
|
||||
}
|
||||
if ( isset( $arr['account_only'] ) || isset( $arr['private_use'] ) ) {
|
||||
unset( $all[$k] );
|
||||
}
|
||||
if ( isset( $arr['type'] ) && in_array( $arr['type'], array('image','file','password') ) ) {
|
||||
unset( $all[$k] );
|
||||
}
|
||||
}
|
||||
|
||||
+7
-31
@@ -334,36 +334,10 @@ class UM_Fields {
|
||||
} else if ( um_user( $key ) && $this->viewing == true ) {
|
||||
|
||||
$value = um_user( $key );
|
||||
$value = apply_filters("um_profile_field_filter_hook__", $value, $data );
|
||||
$value = apply_filters("um_profile_field_filter_hook__{$key}", $value, $data );
|
||||
|
||||
if ( isset( $data['validate'] ) && $data['validate'] != '' && strstr( $data['validate'], 'url' ) ) {
|
||||
$alt = ( isset( $data['url_text'] ) ) ? $data['url_text'] : $value;
|
||||
$url_rel = ( isset( $data['url_rel'] ) ) ? 'rel="nofollow"' : '';
|
||||
|
||||
if ( !strstr( $value, 'http' )
|
||||
&& !strstr( $value, '://' )
|
||||
&& !strstr( $value, 'www.' )
|
||||
&& !strstr( $value, '.com' )
|
||||
&& !strstr( $value, '.net' )
|
||||
&& !strstr( $value, '.org' )
|
||||
) {
|
||||
|
||||
if ( $data['validate'] == 'facebook_url' ) $value = 'http://facebook.com/' . $value;
|
||||
if ( $data['validate'] == 'twitter_url' ) $value = 'http://twitter.com/' . $value;
|
||||
if ( $data['validate'] == 'linkedin_url' ) $value = 'http://linkedin.com/' . $value;
|
||||
if ( $data['validate'] == 'skype' ) $value = 'http://skype.com/' . $value;
|
||||
if ( $data['validate'] == 'googleplus_url' ) $value = 'http://plus.google.com/' . $value;
|
||||
if ( $data['validate'] == 'instagram_url' ) $value = 'http://instagram.com/' . $value;
|
||||
|
||||
}
|
||||
|
||||
$value = '<a href="'. $value .'" target="'.$data['url_target'].'" ' . $url_rel . '>'.$alt.'</a>';
|
||||
}
|
||||
|
||||
if ( is_array( $value ) ) {
|
||||
return implode(', ', $value );
|
||||
}
|
||||
|
||||
return apply_filters("um_profile_field_filter_hook__{$key}", $value );
|
||||
return $value;
|
||||
|
||||
} else if ($default) {
|
||||
return $default;
|
||||
@@ -1418,7 +1392,7 @@ class UM_Fields {
|
||||
|
||||
// Custom filter for field output
|
||||
if ( isset( $this->set_mode ) ) {
|
||||
$output = apply_filters("um_{$key}_form_edit_field", $output, $this->set_mode);
|
||||
$output = apply_filters("um_{$key}_form_edit_field", $output, $this->set_mode);
|
||||
}
|
||||
|
||||
return $output;
|
||||
@@ -1733,7 +1707,9 @@ class UM_Fields {
|
||||
}
|
||||
|
||||
// Custom filter for field output
|
||||
$output = apply_filters("um_{$key}_form_show_field", $output, $this->set_mode);
|
||||
if ( isset( $this->set_mode ) ) {
|
||||
$output = apply_filters("um_{$key}_form_show_field", $output, $this->set_mode);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,53 @@
|
||||
<?php
|
||||
|
||||
/***
|
||||
*** @some required changes before value is shown
|
||||
***/
|
||||
add_filter('um_profile_field_filter_hook__', 'um_profile_field_filter_hook__', 99, 2);
|
||||
function um_profile_field_filter_hook__( $value, $data ) {
|
||||
|
||||
if ( isset( $data['validate'] ) && $data['validate'] != '' && strstr( $data['validate'], 'url' ) ) {
|
||||
$alt = ( isset( $data['url_text'] ) ) ? $data['url_text'] : $value;
|
||||
$url_rel = ( isset( $data['url_rel'] ) ) ? 'rel="nofollow"' : '';
|
||||
|
||||
if( !strstr( $value, 'http' )
|
||||
&& !strstr( $value, '://' )
|
||||
&& !strstr( $value, 'www.' )
|
||||
&& !strstr( $value, '.com' )
|
||||
&& !strstr( $value, '.net' )
|
||||
&& !strstr( $value, '.org' )
|
||||
) {
|
||||
|
||||
if ( $data['validate'] == 'facebook_url' ) $value = 'http://facebook.com/' . $value;
|
||||
if ( $data['validate'] == 'twitter_url' ) $value = 'http://twitter.com/' . $value;
|
||||
if ( $data['validate'] == 'linkedin_url' ) $value = 'http://linkedin.com/' . $value;
|
||||
if ( $data['validate'] == 'skype' ) $value = 'http://skype.com/' . $value;
|
||||
if ( $data['validate'] == 'googleplus_url' ) $value = 'http://plus.google.com/' . $value;
|
||||
if ( $data['validate'] == 'instagram_url' ) $value = 'http://instagram.com/' . $value;
|
||||
|
||||
}
|
||||
|
||||
if ( strpos($value, 'http://') !== 0 ) {
|
||||
$value = 'http://' . $value;
|
||||
}
|
||||
|
||||
$value = '<a href="'. $value .'" target="'.$data['url_target'].'" ' . $url_rel . '>'.$alt.'</a>';
|
||||
}
|
||||
|
||||
if ( !is_array( $value ) ) {
|
||||
|
||||
if ( is_email( $value ) )
|
||||
$value = '<a href="mailto:'. $value.'">'.$value.'</a>';
|
||||
|
||||
} else {
|
||||
|
||||
$value = implode(', ', $value);
|
||||
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @get form fields
|
||||
***/
|
||||
|
||||
+10
-2
@@ -7,12 +7,20 @@ class UM_Profile {
|
||||
}
|
||||
|
||||
function show_meta( $array ) {
|
||||
global $ultimatemember;
|
||||
$output = '';
|
||||
|
||||
foreach( $array as $k ) {
|
||||
if ( $k ) {
|
||||
$items[] = '<span>' . um_user( $k ) . '</span>';
|
||||
$data = '';
|
||||
if ( $k && um_user( $k ) ) {
|
||||
|
||||
$value = um_user( $k );
|
||||
$data = $ultimatemember->builtin->get_specific_field( $k );
|
||||
$value = apply_filters("um_profile_field_filter_hook__", $value, $data );
|
||||
|
||||
$items[] = '<span>' . $value . '</span>';
|
||||
$items[] = '<span class="b">•</span>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ class UM_Setup {
|
||||
'_um_secondary_btn_color' => '#eee',
|
||||
'_um_secondary_btn_hover' => '#e5e5e5',
|
||||
'_um_secondary_btn_text' => '#666',
|
||||
'_um_profile_show_name' => 1,
|
||||
'_um_profile_show_bio' => 1,
|
||||
'_um_profile_role' => '0',
|
||||
'_um_profile_template' => 'profile',
|
||||
|
||||
@@ -440,6 +440,14 @@
|
||||
return $uri;
|
||||
}
|
||||
|
||||
function um_closest_num($array, $number) {
|
||||
sort($array);
|
||||
foreach ($array as $a) {
|
||||
if ($a >= $number) return $a;
|
||||
}
|
||||
return end($array);
|
||||
}
|
||||
|
||||
/***
|
||||
*** @get cover uri
|
||||
***/
|
||||
@@ -461,11 +469,20 @@
|
||||
function um_get_avatar_uri( $image, $attrs ) {
|
||||
global $ultimatemember;
|
||||
$uri = false;
|
||||
if ( file_exists( $ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo.jpg' ) ) {
|
||||
$uri = um_user_uploads_uri() . 'profile_photo.jpg?' . time();
|
||||
}
|
||||
if ( file_exists( $ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo-' . $attrs. '.jpg' ) ){
|
||||
|
||||
if ( file_exists( $ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo-' . $attrs. '.jpg' ) ) {
|
||||
$uri = um_user_uploads_uri() . 'profile_photo-'.$attrs.'.jpg?' . time();
|
||||
} else {
|
||||
|
||||
$sizes = um_get_option('photo_thumb_sizes');
|
||||
$find = um_closest_num( $sizes, $attrs );
|
||||
|
||||
if ( file_exists( $ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo-' . $find. '.jpg' ) ) {
|
||||
$uri = um_user_uploads_uri() . 'profile_photo-'.$find.'.jpg?' . time();
|
||||
} else if ( file_exists( $ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo.jpg' ) ) {
|
||||
$uri = um_user_uploads_uri() . 'profile_photo.jpg?' . time();
|
||||
}
|
||||
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
@@ -494,11 +511,11 @@
|
||||
$value = um_profile($data);
|
||||
|
||||
if ( $ultimatemember->validation->is_serialized( $value ) ) {
|
||||
return unserialize( $value );
|
||||
} else {
|
||||
return $value;
|
||||
$value = unserialize( $value );
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
break;
|
||||
|
||||
case 'full_name':
|
||||
|
||||
@@ -73,6 +73,9 @@ class UM_Shortcodes {
|
||||
}
|
||||
|
||||
$args = apply_filters('um_shortcode_args_filter', $args );
|
||||
|
||||
if ( um_profile_id() && $args['role'] && $args['role'] != $ultimatemember->query->get_role_by_userid( um_profile_id() ) )
|
||||
return;
|
||||
|
||||
extract( $args, EXTR_SKIP );
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class UM_Validation {
|
||||
|
||||
if ( $social ) {
|
||||
|
||||
if ( substr( $url, 0, strlen($social) ) == $social ) { // starts with social requested
|
||||
if ( !filter_var($url, FILTER_VALIDATE_URL) && strstr( $url, $social ) ) { // starts with social requested
|
||||
return true;
|
||||
} else {
|
||||
|
||||
|
||||
+9
-1
@@ -747,7 +747,7 @@ $this->sections[] = array(
|
||||
'type' => 'multi_text',
|
||||
'title' => __( 'Profile Photo Thumbnail Sizes' ),
|
||||
'desc' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.' ),
|
||||
'default' => array( 40, 80, str_replace('px','',um_get_option('profile_photosize') ) ),
|
||||
'default' => array( 40, 80, 190 ),
|
||||
'validate' => 'numeric',
|
||||
'add_text' => __('Add New Size'),
|
||||
),
|
||||
@@ -1192,6 +1192,14 @@ $this->sections[] = array(
|
||||
'transparent' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'id' => 'profile_show_name',
|
||||
'type' => 'switch',
|
||||
'title' => __( 'Show display name in profile header' ),
|
||||
'default' => um_get_metadefault('profile_show_name'),
|
||||
'desc' => 'Switch on/off the user name on profile header',
|
||||
),
|
||||
|
||||
array(
|
||||
'id' => 'profile_show_bio',
|
||||
'type' => 'switch',
|
||||
|
||||
Reference in New Issue
Block a user