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.

 

Script [Closed] hide links for guests

2 Posts
2 Users
0 Reactions
2,098 Views
Posts: 7
Topic starter
(@parsa)
Active Member
Joined: 5 years ago

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

Topic Tags
1 Reply
Robert
Posts: 10616
Admin
(@robert)
Support Team
Joined: 9 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: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/