Notifications
Clear all

Script [Closed] hide links for guests

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

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

Topic Tags
1 Reply
Robert
Posts: 10590
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/