Php 隐藏特定页面的CSS类,但不隐藏该页面的URI/路径

Php 隐藏特定页面的CSS类,但不隐藏该页面的URI/路径,php,wordpress,class,hide,uri,Php,Wordpress,Class,Hide,Uri,背景资料: 我有一个Wordpress插件来显示每个用户配置文件前端。当登录用户访问其配置文件时。url是/profile/。当用户访问另一个配置文件时,路径相同,后跟用户名/profile/bob1/例如 使用一些div类,我创建了一个模糊的背景,上面有另一个图像,以阻止某些Wordpress用户看到个人资料信息 问题是: 我想知道如何隐藏这些div类,而不是它们自己的配置文件页:/profile/而是它的所有其他路径/profile/bob1/例如,以及下面可以看到的其他“if”条件: 正如

背景资料:

我有一个Wordpress插件来显示每个用户配置文件前端。当登录用户访问其配置文件时。url是/profile/。当用户访问另一个配置文件时,路径相同,后跟用户名/profile/bob1/例如

使用一些div类,我创建了一个模糊的背景,上面有另一个图像,以阻止某些Wordpress用户看到个人资料信息

问题是:

我想知道如何隐藏这些div类,而不是它们自己的配置文件页:/profile/而是它的所有其他路径/profile/bob1/例如,以及下面可以看到的其他“if”条件:

正如您所见,我只向具有Wordpress“读取”功能的特定用户显示了一个div类

    <div class="back"<?php if (current_user_can('read')){ echo 'style="display:none;"'; } ?>></div>

非常感谢您看这个!非常感谢。

来自WordPress文档中的

因此,应用同样的逻辑

<?php 
$viewother = (isset($_GET['author_name'])) ? true : false;
?>
或者您可以检查用户ID

<?php
$style = '';
$curauth = get_userdata(intval($author));
$otherauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : false;
if($otherauth && $otherauth->ID != $curauth->ID) {
    // user is viewing another profile
    $style = ' style="display:none;"';
}
?>

<div class="back"<?php echo $style; } ?>></div>

为了清楚起见,我需要将“当前用户”保存在那里。谢谢。如果你使用的是PHP,为什么还要包含配置文件信息呢?当然,一个精明的用户所要做的就是将网页保存在本地并修改样式声明。非常感谢@slapyo。我对PHP完全是个新手。请你展示一下你的代码是如何与我上面写的代码相结合的。非常感谢。
<?php
$style = '';
$curauth = get_userdata(intval($author));
$otherauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : false;
if($otherauth && $otherauth->ID != $curauth->ID) {
    // user is viewing another profile
    $style = ' style="display:none;"';
}
?>

<div class="back"<?php echo $style; } ?>></div>