mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Merge pull request #103 from jonfalcon/master
Fix honorifics in full name
This commit is contained in:
@@ -240,11 +240,10 @@ class UM_Permalinks {
|
||||
if( in_array( um_get_option( 'permalink_base'), $full_name_permalinks ) )
|
||||
{
|
||||
$full_name = um_user( 'full_name' );
|
||||
$count = $wpdb->get_var( $wpdb->prepare(
|
||||
"SELECT COUNT(*) as count FROM %s WHERE meta_key = 'full_name' && meta_value = %s ",
|
||||
$wpdb->usermeta,
|
||||
um_user( 'full_name' )
|
||||
) );
|
||||
$count = intval( $wpdb->get_var( $wpdb->prepare(
|
||||
"SELECT COUNT(*) as count FROM {$wpdb->usermeta} WHERE meta_key = 'full_name' AND meta_value = '%s'",
|
||||
$full_name
|
||||
) ) );
|
||||
|
||||
if( $count > 1 )
|
||||
{
|
||||
|
||||
+40
-40
@@ -3,17 +3,17 @@
|
||||
class UM_Rewrite {
|
||||
|
||||
function __construct() {
|
||||
|
||||
|
||||
add_filter('query_vars', array(&$this, 'query_vars'), 10, 1 );
|
||||
|
||||
|
||||
add_action('init', array(&$this, 'rewrite_rules'), 100000000 );
|
||||
|
||||
|
||||
add_action('template_redirect', array(&$this, 'redirect_author_page'), 9999 );
|
||||
|
||||
|
||||
add_action('template_redirect', array(&$this, 'locate_user_profile'), 9999 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @modify global query vars
|
||||
***/
|
||||
@@ -24,7 +24,7 @@ class UM_Rewrite {
|
||||
$public_query_vars[] = 'subnav';
|
||||
return $public_query_vars;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @setup rewrite rules
|
||||
***/
|
||||
@@ -33,21 +33,21 @@ class UM_Rewrite {
|
||||
global $ultimatemember;
|
||||
|
||||
if ( isset( $ultimatemember->permalinks->core['user'] ) && !um_get_option('um_flush_stop') ) {
|
||||
|
||||
|
||||
$user_page_id = $ultimatemember->permalinks->core['user'];
|
||||
$account_page_id = $ultimatemember->permalinks->core['account'];
|
||||
$user = get_post($user_page_id);
|
||||
|
||||
|
||||
if ( isset( $user->post_name ) ) {
|
||||
|
||||
|
||||
$user_slug = $user->post_name;
|
||||
$account = get_post($account_page_id);
|
||||
$account_slug = $account->post_name;
|
||||
|
||||
$add_lang_code = '';
|
||||
|
||||
|
||||
if ( function_exists('icl_object_id') || function_exists('icl_get_current_language') ) {
|
||||
|
||||
|
||||
if( function_exists('icl_get_current_language') ){
|
||||
$language_code = icl_get_current_language();
|
||||
}else if( function_exists('icl_object_id') ){
|
||||
@@ -60,7 +60,7 @@ class UM_Rewrite {
|
||||
if( isset( $lang_post_obj->post_name ) ){
|
||||
$user_slug = $lang_post_obj->post_name;
|
||||
}
|
||||
|
||||
|
||||
// Account page translated slug
|
||||
$lang_post_id = icl_object_id( $account->ID, 'post', FALSE, $language_code );
|
||||
$lang_post_obj = get_post( $lang_post_id );
|
||||
@@ -71,28 +71,28 @@ class UM_Rewrite {
|
||||
if( $language_code != icl_get_default_language() ){
|
||||
$add_lang_code = $language_code;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_rewrite_rule( $user_slug.'/([^/]+)/?$',
|
||||
'index.php?page_id='.$user_page_id.'&um_user=$matches[1]&lang='.$add_lang_code,
|
||||
'top'
|
||||
);
|
||||
|
||||
|
||||
add_rewrite_rule( $account_slug.'/([^/]+)?$',
|
||||
'index.php?page_id='.$account_page_id.'&um_tab=$matches[1]&lang='.$add_lang_code,
|
||||
'top'
|
||||
);
|
||||
|
||||
|
||||
|
||||
flush_rewrite_rules( true );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @author page to user profile redirect
|
||||
***/
|
||||
@@ -103,19 +103,19 @@ class UM_Rewrite {
|
||||
exit( wp_redirect( um_user_profile_url() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @locate/display a profile
|
||||
***/
|
||||
function locate_user_profile() {
|
||||
global $post, $ultimatemember;
|
||||
|
||||
|
||||
if ( um_queried_user() && um_is_core_page('user') ) {
|
||||
|
||||
|
||||
if ( um_get_option('permalink_base') == 'user_login' ) {
|
||||
|
||||
|
||||
$user_id = username_exists( um_queried_user() );
|
||||
|
||||
|
||||
// Try nice name
|
||||
if ( !$user_id ) {
|
||||
$slug = um_queried_user();
|
||||
@@ -125,50 +125,50 @@ class UM_Rewrite {
|
||||
$user_id = $the_user->ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( um_get_option('permalink_base') == 'user_id' ) {
|
||||
$user_id = $ultimatemember->user->user_exists_by_id( um_queried_user() );
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( in_array( um_get_option('permalink_base'), array('name','name_dash','name_dot','name_plus') ) ) {
|
||||
$user_id = $ultimatemember->user->user_exists_by_name( um_queried_user() );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** USER EXISTS SET USER AND CONTINUE **/
|
||||
|
||||
|
||||
if ( $user_id ) {
|
||||
|
||||
|
||||
um_set_requested_user( $user_id );
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
exit( wp_redirect( um_get_core_page('user') ) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else if ( um_is_core_page('user') ) {
|
||||
|
||||
|
||||
if ( is_user_logged_in() ) { // just redirect to their profile
|
||||
|
||||
|
||||
$query = $ultimatemember->permalinks->get_query_array();
|
||||
|
||||
|
||||
$url = um_user_profile_url();
|
||||
|
||||
|
||||
if ( $query ) {
|
||||
foreach( $query as $key => $val ) {
|
||||
$url = add_query_arg($key, $val, $url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
exit( wp_redirect( $url ) );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +66,15 @@
|
||||
/***
|
||||
*** @user clean basename
|
||||
***/
|
||||
function um_clean_user_basename( $value ){
|
||||
function um_clean_user_basename( $value ) {
|
||||
|
||||
$value = str_replace('<hon>', '', $value);
|
||||
$value = preg_replace('/^([a-z]{2,3})\./', '$1<hon>', $value);
|
||||
$value = preg_replace('/([a-z]{2,3})\.$/', '$1<hon>', $value);
|
||||
$value = str_replace('.', ' ', $value);
|
||||
$value = str_replace('-', ' ', $value);
|
||||
$value = str_replace('+', ' ', $value);
|
||||
$value = str_replace('<hon>', '.', $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
+1
-1
@@ -886,7 +886,7 @@ class UM_User {
|
||||
$value = um_clean_user_basename( $value );
|
||||
|
||||
// if duplicate full name, return the user id
|
||||
if( preg_match( '/\d+$/', $value, $matches ) )
|
||||
if( preg_match( '/( |\.|\-)\d+$/', $value, $matches ) )
|
||||
{
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user