Skip to:
Content
Pages
Categories
Search
Top
Bottom

Looking for the right hook

  • I’m REALLY new at making plugins. Let’s start there.

    I’m looking to hide certain forums from a defined list of people. Or actually, I’m looking to only allow certain people to see certain forums. Anyway, I’m starting with just trying to make that happen on the front page. How do I “hijack” the page just at the point where it is about to spit out the forums on the front-page? I think this is what hooks are for right? So that I don’t need to actually edit my front-page.php?

    Basically what I am looking to do, is during the “foreach” loop in front-page.php, I want to compare the upcoming forum_id with a list of usernames in an array who are allowed to see that forum. If there’s a match, it shows the forum, if not, it doesn’t.

    The array looks like this:

    $forum_restriction_keys = array(

    "1" => "bob, sam, jim, jane",

    "3" = > "bob",

    );

    So, to start, I need the right hook.

Viewing 1 replies (of 1 total)
  • OK look at this:

    $forum_restrict_keys = array(

    "1" => "davidbessler,testman",

    "3" => "davidbessler,",

    );

    function forum_restrict_check_name() {

    global $bb_current_user,$forum_restrict_keys;

    if ($bb_current_user){

    $allowed = strpos($forum_restrict_keys[get_forum_id()], get_user_name( $bb_current_user->ID ));

    if ($allowed == "") {

    echo "[blocked]";

    add_filter( 'get_forum_name', 'forum_restrict_blank_name');

    } else {

    echo "[Not blocked]";

    }

    }

    }

    function forum_restrict_blank_name (){

    echo "";

    }

    add_action( 'get_forum_name', 'forum_restrict_check_name');

    ?>

    That puts [blocked] instead of the forum name in a forum that user is not allowed to see, and [not blocked] on a forum he is allowed to see. How do I get the forum name back in there instead of [not blocked]?

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar