mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- added ability to search users by user_login slug when custom meta permalink set in the settings but not isset for the user;
This commit is contained in:
@@ -149,9 +149,13 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate/display a profile.
|
||||
* Getting the user_id based on the User Profile slug like when Base Permalink setting equals 'user_login'.
|
||||
*
|
||||
* @since 2.6.12
|
||||
*
|
||||
* @return bool|int|mixed
|
||||
*/
|
||||
public function locate_user_profile() {
|
||||
private function get_user_id_by_user_login_slug() {
|
||||
$permalink_base = UM()->options()->get( 'permalink_base' );
|
||||
if ( 'custom_meta' === $permalink_base ) {
|
||||
$custom_meta = UM()->options()->get( 'permalink_base_custom_meta' );
|
||||
@@ -161,8 +165,6 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( um_queried_user() && um_is_core_page( 'user' ) ) {
|
||||
if ( 'user_login' === $permalink_base ) {
|
||||
$user_id = username_exists( um_queried_user() );
|
||||
//Try
|
||||
if ( ! $user_id ) {
|
||||
@@ -202,6 +204,26 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) {
|
||||
$user_id = UM()->user()->user_exists_by_email_as_username( $slug );
|
||||
}
|
||||
}
|
||||
|
||||
return $user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate/display a profile.
|
||||
*/
|
||||
public function locate_user_profile() {
|
||||
$permalink_base = UM()->options()->get( 'permalink_base' );
|
||||
if ( 'custom_meta' === $permalink_base ) {
|
||||
$custom_meta = UM()->options()->get( 'permalink_base_custom_meta' );
|
||||
if ( empty( $custom_meta ) ) {
|
||||
// Set default permalink base if custom meta is empty.
|
||||
$permalink_base = 'user_login';
|
||||
}
|
||||
}
|
||||
|
||||
if ( um_queried_user() && um_is_core_page( 'user' ) ) {
|
||||
if ( 'user_login' === $permalink_base ) {
|
||||
$user_id = $this->get_user_id_by_user_login_slug();
|
||||
}
|
||||
|
||||
if ( 'user_id' === $permalink_base ) {
|
||||
@@ -214,6 +236,10 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) {
|
||||
|
||||
if ( 'custom_meta' === $permalink_base ) {
|
||||
$user_id = UM()->user()->user_exists_by_custom_meta( um_queried_user() );
|
||||
if ( ! $user_id ) {
|
||||
// Try user_login by default.
|
||||
$user_id = $this->get_user_id_by_user_login_slug();
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( $permalink_base, array( 'name', 'name_dash', 'name_dot', 'name_plus' ), true ) ) {
|
||||
|
||||
Reference in New Issue
Block a user