简体   繁体   English

如何从内容中隐藏/模糊 email 地址和电话号码?

[英]How to hide/blur email address and phone number from content?

I'm recently working on WP Project, where we need to blur the email address and phone number from content for all the logout users, and when they log in they can see the email address and phone number.我最近在 WP 项目上工作,我们需要从所有注销用户的内容中模糊 email 地址和电话号码,当他们登录时,他们可以看到 email 地址和电话号码。 I'm looking for its solution from hours but didn't able to find any.我一直在寻找它的解决方案,但没有找到任何解决方案。

Experts help required , I'm not sure if it can be done by JS or PHP?需要专家帮助,我不确定是否可以通过 JS 或 PHP 来完成?

You shouldn't blur the emails after you've already sent them, as anybody can just disable a css effect and view the email.您不应在发送电子邮件后对其进行模糊处理,因为任何人都可以禁用 css 效果并查看 email。 What you should do is replace all the emails with a fake email placeholder such as example@example.com and then add a filter: blur(3px);您应该做的是将所有电子邮件替换为假 email 占位符,例如example@example.com ,然后添加filter: blur(3px); on that elements CSS.在那个元素上 CSS。 This will blur the email and prevent anybody from viewing the email by disabling the CSS.这将模糊 email 并通过禁用 CSS 防止任何人查看 email。

Since you didn't provide any PHP, I might recommend that you do a simple conditional such as:由于您没有提供任何 PHP,我可能会建议您执行一个简单的条件,例如:

if($isLoggedIn) {
   $email = $actualEmail;
   echo $email;
} else {
   $email = 'example@example.com';
   echo '<p class="hidden-email">'.$email.'</p>';
}

CSS: CSS:

.hidden-email {
    filter: blur(3px);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM