The general users setting "Avoid indexing profile by search engines" is added.

The user role setting "Avoid indexing profile by search engines" is changed.
This commit is contained in:
denisbaranov
2020-12-22 20:13:58 +02:00
parent 85b6bfdc5f
commit 0fdb5635eb
4 changed files with 75 additions and 22 deletions
+46
View File
@@ -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 <?php UM()->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.
*