Notifications
Clear all

Paid Addons Support Forum Only

Please note, that here we only support Paid Addons issues and questions.

gVectors Support staff works from 6am to 6pm (GMT+0)

All questions related to wpForo and wpDiscuz free plugins should be asked in the corresponding plugin support forum:

 

wpDiscuz Support Forum wpForo Support Forum

[Solved] Hide Pre Code for Guest


Tutrix
Posts: 40
Customer
Topic starter
(@tutrix)
Member
Joined: 2 years ago

Is there a way to hide pre code for guests

Example via CSS class ".logged-in"

Pre Code display:none; for Guest

but "display: none;" can be deactivated in the CSS by the guests

4 Replies
Tom
Posts: 3822
 Tom
Admin
(@tomson)
Support Team
Joined: 7 years ago

Hi @tutrix,

As far as I see you've already solved this task. Haven't you?

2 Replies
Tutrix
Customer
(@tutrix)
Joined: 2 years ago

Member
Posts: 40
Posted by: @tomson

Haven't you?

Unfortunately no, this is with CSS display: none; realized
The code can be made visible via the Browser Inspector

Tom
 Tom
Admin
(@tomson)
Joined: 7 years ago

Support Team
Posts: 3822

@tutrix,

Try this. Put it in your current active WordPress theme functions.php file:

add_filter('wpforo_content_after', 'wpforo_hide_pre_for_guests', 10);
function wpforo_hide_pre_for_guests( $content ){
if( WPF()->current_user_groupid === 4 ){
$content = preg_replace('|<pre[^><]*>.+?<\/pre>|ism', '<a href="#" rel="nofollow">[' . wpforo_phrase('Please login to see the script', false) . ']</a>', $content);
}
return $content;
}
Tutrix
Posts: 40
Customer
Topic starter
(@tutrix)
Member
Joined: 2 years ago

Hi @Tom

thank you very much, that works perfectly 😀 

Share:
Scroll to top