Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Hide Links

I think should do it, it’s based off code here: https://bbpress.org/forums/topic/open-links-in-new-window

Change the values of $forums to the forum IDs of those you wish to restrict (it’ll only work on direct parent forums, not grandparents or categories, I don’t want to include walker code unless people need it).

Tested on 1.0.2 trunk, so I’m not 100% sure it’ll run on 0.9, sorry.

<?php
/*
Plugin Name: Remove Links (conditional)
Description: Removes links for non-registered users. Based on <a href="http://ckon.wordpress.com/2007/07/12/bbpress-plugin-bb-tweaks/">bb tweaks</a>.
Plugin URI: https://bbpress.org/forums/topic/hide-links
Version: 0.01
*/

function bb_strip_links( $text ) {
global $topic;

$forums = array(
1,
2,
3,
);

if ( !in_array( $topic->forum_id, $forums ) )
return $text;

if ( !bb_current_user_can( 'write_post' ) )
$text = preg_replace('|<a (.+?)>(.+?)</a>|i', 'Login or register to download', $text);

return $text;

}

add_filter('post_text', 'bb_strip_links');

?>

@Hanratty: hiding links using CSS visibility will still leave the link URLs in the code, which isn’t too desirable for some

Skip to toolbar