diff --git a/core/um-actions-register.php b/core/um-actions-register.php index eb0775fa..1df62940 100644 --- a/core/um-actions-register.php +++ b/core/um-actions-register.php @@ -52,6 +52,12 @@ $user_login = strtolower( str_replace(" ","",$first_name." ".$last_name ) ); } + // if full name exists + $count = 1; + while( username_exists( $user_login ) ) { + $user_login .= $count; + $count++; + } } if( !isset( $user_login ) && isset( $user_email ) && $user_email ) diff --git a/core/um-permalinks.php b/core/um-permalinks.php index f78a22d3..63000674 100644 --- a/core/um-permalinks.php +++ b/core/um-permalinks.php @@ -186,7 +186,7 @@ class UM_Permalinks { *** @get profile url for set user ***/ function profile_url() { - global $ultimatemember; + global $ultimatemember, $wpdb; $page_id = $this->core['user']; $profile_url = get_permalink( $page_id ); @@ -236,16 +236,33 @@ class UM_Permalinks { $user_in_url = um_user('ID'); } - if ( um_get_option('permalink_base') == 'name' ) { - $user_in_url = rawurlencode( strtolower( str_replace(" ",".",um_user('full_name') ) ) ); - } + $full_name_permalinks = array( 'name', 'name_dash', 'name_plus' ); + if( in_array( um_get_option( 'permalink_base'), $full_name_permalinks ) ) + { + $full_name = um_user( 'full_name' ); + $count = $wpdb->get_var( sprintf( + "SELECT COUNT(*) as count FROM %s WHERE meta_key = 'full_name' && meta_value = '%s'", + $wpdb->usermeta, + um_user( 'full_name' ) + ) ); - if ( um_get_option('permalink_base') == 'name_dash' ) { - $user_in_url = rawurlencode( strtolower( str_replace(" ","-",um_user('full_name') ) ) ); - } + if( $count > 1 ) + { + $full_name .= ' ' . um_user( 'ID' ); + } - if ( um_get_option('permalink_base') == 'name_plus' ) { - $user_in_url = strtolower( str_replace(" ","+",um_user('full_name') ) ); + switch( um_get_option('permalink_base') ) + { + case 'name': + $user_in_url = rawurlencode( strtolower( str_replace( " ", ".", $full_name ) ) ); + break; + case 'name_dash': + $user_in_url = rawurlencode( strtolower( str_replace(" ", "-", $full_name ) ) ); + break; + case 'name_plus': + $user_in_url = strtolower( str_replace(" ", "+" , $full_name ) ); + break; + } } if ( get_option('permalink_structure') ) { diff --git a/core/um-short-functions.php b/core/um-short-functions.php index e4828bff..8c03cd8f 100644 --- a/core/um-short-functions.php +++ b/core/um-short-functions.php @@ -71,6 +71,7 @@ $value = str_replace('.', ' ', $value); $value = str_replace('-', ' ', $value); $value = str_replace('+', ' ', $value); + $value = preg_replace('/\d+$/', '', $value); return $value; } @@ -295,7 +296,7 @@ function um_user_ip() { $k = __('date submitted','ultimatemember'); $v = date("d M Y H:i", $v); } - + if ( $style ) { if ( !$v ) $v = __('(empty)','ultimatemember'); $output .= "
$v
"; @@ -1329,7 +1330,7 @@ function um_fetch_user( $user_id ) { break; case 'profile_photo': - + $has_profile_photo = false; if ( um_profile('profile_photo') ) { @@ -1340,9 +1341,9 @@ function um_fetch_user( $user_id ) { } $avatar_uri = apply_filters('um_user_avatar_url_filter', $avatar_uri, um_user('ID') ); - + if ( $avatar_uri ) - + if( um_get_option('use_gravatars') && ! um_user('synced_profile_photo') && ! $has_profile_photo ){ $avatar_uri = um_get_domain_protocol().'gravatar.com/avatar/'.um_user('synced_gravatar_hashed_id'); $avatar_uri = add_query_arg('s',400, $avatar_uri); @@ -1385,7 +1386,7 @@ function um_fetch_user( $user_id ) { } else { $protocol = 'http://'; } - + return $protocol; }