New: The user role setting 'Avoid indexing profile by search engines'

This commit is contained in:
denisbaranov
2020-12-15 17:25:24 +02:00
parent fc3902e346
commit 3ffb8257af
3 changed files with 26 additions and 6 deletions
@@ -40,6 +40,14 @@
'label' => __( 'Can view/access private profiles?', 'ultimate-member' ),
'tooltip' => __( 'Can this role view private profiles?', 'ultimate-member' ),
'value' => ! empty( $role['_um_can_access_private_profile'] ) ? $role['_um_can_access_private_profile'] : 0,
),
array(
'id' => '_um_profile_noindex',
'type' => 'checkbox',
'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,
)
)
) )->render_form(); ?>
+1 -1
View File
@@ -1139,7 +1139,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
'required' => 0,
'public' => 1,
'editable' => 1,
'default' => '0',
'default' => UM()->roles()->um_user_can( 'profile_noindex' ) ? '1' : '0',
'options' => array(
'0' => __( 'No', 'ultimate-member' ),
'1' => __( 'Yes', 'ultimate-member' ),
+17 -5
View File
@@ -682,15 +682,27 @@ function um_profile_dynamic_meta_desc() {
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
if ( $privacy == __( 'Only me', 'ultimate-member' ) || $privacy == 'Only me' ) {
echo '<meta name="robots" content="noindex, nofollow" />';
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 '<meta name="robots" content="noindex, nofollow" />';
return;
}
/**
* @see the account setting "Avoid indexing my profile by search engines"
*/
$noindex = get_user_meta( $user_id, 'profile_noindex', true );
if ( ! empty( $noindex ) ) { ?>
<meta name="robots" content="noindex, nofollow" />
<?php return;
if ( ! empty( $noindex ) ) {
echo '<meta name="robots" content="noindex, nofollow" />';
return;
}
um_fetch_user( $user_id );