Restricting Content in Template Files

如果您想限制主题或插件模板文件的某些部分,Restrict Content Pro 提供了一系列功能,可让您执行此作。请参阅函数参考,了解您可以使用的功能的完整列表。

从 3.0.5 版本开始,您将使用的主要函数是 rcp_user_has_active_membership()。如果您使用的是旧版本的 Restrict Content Pro,那么您可以以完全相同的方式使用rcp_is_active()。

它们是非常简单易用的函数:


    Content inside here would only be visible to active members.

或者在 3.0.5 之前的版本中:


    Content inside here would only be visible to active members.

这会将条件之间的内容限制为具有有效订阅的成员。如果您只想将可见性限制为拥有付费订阅的客户,则需要改用 rcp_user_has_paid_membership()。


    Content inside here would only be visible to active paid and active free subscribers.

您还可以执行更高级的检查(请参阅上面链接的函数参考)。例如,您可以仅向具有特定成员资格级别的活动成员显示内容。

如果您使用的是 3.0.5 或更高版本,则可以使用以下内容:


    Content inside here would only be visible to active members with a membership level ID of 2.

否则,如果您使用的是旧版本的 RCP,则可以使用以下内容:


    Content inside here would only be visible to active subscribers with a subscription level ID of 2.

在这两个示例中,只需将数字“2”更改为您要检查的 ID 号即可。

根据元框设置限制内容

如果要向自定义页面模板添加限制,则可能需要根据该页面的元框设置设置 PHP 限制。这可以使用 rcp_user_can_access()函数来完成。这将根据您在 “Restrict this content” 元框中选择的设置来检查当前用户是否有权查看当前页面。


    Content inside here would only be visible to people who meet the requirements you've set in the "Restrict this content" meta box.

RCP_Member类有助于确定成员是否也有权访问内容。

如果您只想允许活跃成员在您的网站上发表评论,则需要自定义模板的 comments.php 文件。

要限制对评论发布的访问,请在 comments.php 文件中找到以下行:

现在让我们调整它,以便只有活跃的成员才能发表评论。

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇