I also need something like that.
Is there any plugin or code?
nothing I know of would do that
You can use bbp_get_reply_content
filter, but this can be a disaster when you take off all the links that other plugins or the theme could have in the reply content. A good example is the mentions being added by BuddyPress, but after using this, they turn into the restriction notice..
add_filter('bbp_get_reply_content', 'restricted_links', 20, 2);
function restricted_links($content, $post_id) {
if ( is_user_logged_in() )
return $content;
return preg_replace_callback( '/<a(.*?)href(.*?)>(.*?)<\/a>/si', function($m){
return sprintf(
'<span class="protected-link" style="background:#f3f3f3;padding: 2px 5px;display:inline-block;border-radius:3px">[Restricted Link] Please <a href="%s">register</a> to view this link</span>',
home_url('/wp-login.php?action=register')
);
}, $content );
}
You may pass-in the link text after the notice or something, it is all up to you so play around with the code or ping me if you needed help.
Thank you, the code works properly 🙂