Hello
I want a code to use in the function file of bbPress to hide all links in the content of forum’s topics and replies for visitors.
I mean until a visitor is not logged in the forum, instead of displaying links, it shows a text message like “displaying links to members only” and a registration link to register and enter his account so that redirects to the last page in the topic or reply.
Additional Explanation:
I Use the code below:
add_filter( 'the_content', 'content_link_for_user_snippets', 1 );
function content_link_for_user_snippets( $content = '' ) {
// Snippets.ir
if( ! is_user_logged_in() ) {
preg_match_all( "#<a(.*?)>(.*?)#i", $content, $matches );
$num = count( $matches[0] );
for( $i = 0; $i < $num; $i++ ) {
$content = str_replace( $matches[0][ $i ], '<a href="' . ( get_permalink() ) . '"><span style="color:#F00;">[displaying links to members only]<span></a>', $content );
}
}
return $content;
}
in My site’s Theme and word very nice but it doesn’t have any effect in form and couldn’t use it in bbPress function’ file.