Notifications
Clear all

Limited Support

Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed. We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.

 

[Solved] Hide Pre Code for Guest

5 Posts
2 Users
1 Reactions
2,295 Views
Tutrix
Posts: 79
Customer
Topic starter
(@tutrix)
Member
Joined: 5 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
Posts: 4233
 Tom
Admin
(@tomson)
Famed Member
Joined: 10 years ago

Hi @tutrix,

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

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

Member
Posts: 79
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
Admin
(@tomson)
Joined: 10 years ago

Famed Member
Posts: 4233

@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: 79
Customer
Topic starter
(@tutrix)
Member
Joined: 5 years ago

Hi @Tom

thank you very much, that works perfectly 😀Β 

Share:
Scroll to top