diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php
index 53a8e21e..73e5e848 100644
--- a/includes/admin/core/class-admin-settings.php
+++ b/includes/admin/core/class-admin-settings.php
@@ -630,6 +630,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'type' => 'checkbox',
'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ),
'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ),
+ ),
+ array(
+ 'id' => 'profile_noindex',
+ 'type' => 'select',
+ 'size' => 'small',
+ 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
+ 'tooltip' => __( 'Hides the profile page for robots.', 'ultimate-member' ) . ' ' . __( 'This setting can be overridden by individual role settings.', 'ultimate-member' ),
+ 'options' => [
+ '1' => __( 'Yes', 'ultimate-member' ),
+ '' => __( 'No', 'ultimate-member' )
+ ]
)
)
),
diff --git a/includes/admin/templates/role/profile.php b/includes/admin/templates/role/profile.php
index 48a5115c..0b19c247 100644
--- a/includes/admin/templates/role/profile.php
+++ b/includes/admin/templates/role/profile.php
@@ -43,11 +43,17 @@
),
array(
'id' => '_um_profile_noindex',
- 'type' => 'checkbox',
+ 'type' => 'select',
+ 'size' => 'medium',
'name' => '_um_profile_noindex',
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
- 'tooltip' => __( 'Hides the profile page for robots', 'ultimate-member' ),
- 'value' => ! empty( $role['_um_profile_noindex'] ) ? $role['_um_profile_noindex'] : 0,
+ 'tooltip' => __( 'Hides the profile page for robots.', 'ultimate-member' ) . ' ' . __( 'The default value depends on the general users settings.', 'ultimate-member' ),
+ 'options' => [
+ '' => __( 'Default', 'ultimate-member' ),
+ '1' => __( 'Yes', 'ultimate-member' ),
+ '2' => __( 'No', 'ultimate-member' )
+ ],
+ 'value' => ! empty( $role['_um_profile_noindex'] ) ? $role['_um_profile_noindex'] : '',
)
)
) )->render_form(); ?>
diff --git a/includes/core/class-user.php b/includes/core/class-user.php
index 08b31861..1c6138be 100644
--- a/includes/core/class-user.php
+++ b/includes/core/class-user.php
@@ -1686,6 +1686,52 @@ if ( ! class_exists( 'um\core\User' ) ) {
}
+ /**
+ * This method checks if the profile indexing is disabled
+ *
+ * @since 2.1.14 [2020-12-22]
+ * @usage user()->is_profile_noindex(); ?>
+ *
+ * @return boolean Is the profile indexing disabled?
+ */
+ function is_profile_noindex(){
+ $user_id = $this->id;
+
+ $profile_noindex = false;
+
+ if ( !get_option( 'blog_public' ) ){
+ // Option "Search engine visibility" in [wp-admin > Settings > Reading]
+ $profile_noindex = true;
+
+ } elseif ( $this->is_private_profile( $user_id ) ){
+ // Setting "Profile Privacy" in [Account > Privacy]
+ $profile_noindex = true;
+
+ } elseif ( get_user_meta( $user_id, 'profile_noindex', true ) === '1' ){
+ // Setting "Avoid indexing my profile by search engines in [Account > Privacy]
+ $profile_noindex = true;
+
+ }
+
+ if( ! $profile_noindex ){
+ $role = UM()->roles()->get_priority_user_role( $user_id );
+ $permissions = UM()->roles()->role_data( $role );
+
+ if ( isset( $permissions['profile_noindex'] ) && $permissions['profile_noindex'] === '1' ) {
+ // Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
+ $profile_noindex = true;
+
+ } elseif ( empty( $permissions['profile_noindex'] ) && UM()->options()->get( 'profile_noindex' ) === '1' ){
+ // Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
+ $profile_noindex = true;
+
+ }
+ }
+
+ return apply_filters( 'um_user_is_profile_noindex', $profile_noindex, $this );
+ }
+
+
/**
* This method checks if give user profile is private.
*
diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php
index b7880086..e6b343c5 100644
--- a/includes/core/um-actions-profile.php
+++ b/includes/core/um-actions-profile.php
@@ -680,33 +680,23 @@ function um_profile_dynamic_meta_desc() {
$user_id = um_get_requested_user();
- $privacy = get_user_meta( $user_id, 'profile_privacy', true );
- if ( $privacy == __( 'Only me', 'ultimate-member' ) || $privacy == 'Only me' ) {
- echo '';
- return;
- }
-
- /**
- * @see the user role setting "Avoid indexing profile by search engines"
- */
- $role = UM()->roles()->get_priority_user_role( $user_id );
- $permissions = UM()->roles()->role_data( $role );
- if ( ! empty( $permissions['profile_noindex'] ) ) {
- echo '';
- return;
+ if( $user_id !== um_user('ID') ){
+ um_fetch_user( $user_id );
}
/**
- * @see the account setting "Avoid indexing my profile by search engines"
+ * Settings by the priority:
+ * "Search engine visibility" in [wp-admin > Settings > Reading]
+ * "Profile Privacy" in [Account > Privacy]
+ * "Avoid indexing my profile by search engines in [Account > Privacy]
+ * "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
+ * "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
*/
- $noindex = get_user_meta( $user_id, 'profile_noindex', true );
- if ( ! empty( $noindex ) ) {
+ if ( UM()->user()->is_profile_noindex() ) {
echo '';
return;
}
- um_fetch_user( $user_id );
-
$locale = get_user_locale( $user_id );
$site_name = get_bloginfo( 'name' );
$twitter_site = '@' . sanitize_title( $site_name );