Clear all

Script [Closed] hide links for guests

2 Posts
2 Users
0 Reactions
Posts: 7
Topic starter
Active Member
Joined: 3 years ago

What is the simple way to hide links for guests in wpforo?

Topic Tags
1 Reply
Posts: 10525
Support Team
Joined: 8 years ago

Hi @parsa,

You should use this small hook code in your current active WordPress theme's functions.php file:

add_filter('wpforo_content_after', 'wpforo_hide_links_for_guests', 10);
function wpforo_hide_links_for_guests( $content ){
if( WPF()->current_user_groupid === 4 ){
$content = preg_replace('|<a[^>]+href=[^>]+>[^<>]+<\/a>|im', '<a href="#" rel="nofollow">[' . wpforo_phrase('Please login to see the link', false) . ']</a>', $content);
return $content;

Here is a good article how to add such codes to the website in case you cannot add it in the functions.php file: