Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hooks & Filters Docu

  • Rather than just keeping private notes on the hooks and filters I found, I thought it best to maybe start a list here with everyone, just as a rough working documentation of the hooks and filters.

    For future ref/for people that don’t know, a hook is a means of bbPress making your plugin run every time a certain thing happens. To get that to work, put this code at the very bottom of your plugin:

    add_action( 'hook_name', 'functionname' );

    Filters are very similar to hooks, only it gives your plugin some data, you can then do something with the data (filter it), and then pass it back. To register for filters, put this code at the bottom of your application; remember to accept the parameters in your function and return them as appropriate.

    add_filter( 'filter_name', 'functionname' );

    Note that in both cases you want the name as a string and the function’s name as a string, no brackets or parameters at the end of it! An optional third parameter is the priority of your function; default is 10, so set this higher if you want it to execute last or lower if you want it to execute earlier.

    Some Filters

    topic_title – this passes the topic title to your function when the threads are being listed, like on the (default) front page.

    bb_allowed_tags – this is the array of HTML tags you can use in your posts. Hang a filter on this and add elements to the array if you want to allow more tags.

    Some Hooks

    bb_head – this is called when the HTML <head> element is being filled, so you can add stylesheets or javascript and the like.

    bb_user_logout obviously gets called when someone logs out.

    bb_init when someone logs in?

    bb_new_user when someone registers; passes the ID along I think

    bb_profile_menu – haven’t figured out how it works; I think it’s to do with the tabs at the top of the profile.

    If you know any more hooks or filters, or find ’em, please post them here with a quick description if necessary!

Viewing 12 replies - 26 through 37 (of 37 total)
  • hey cool.

    i was just looking for something like this and you just created it minutes ago!

    i guess i’m too early.. not much there yet obviously.

    in the meantime, anyone out there know the filter/action that would allow me to disable the bbpress registration page entirely ( ie: registration.php ) ?

    i’d love to do this via a plugin rather that hack the core bbpress files or delete/move the file altogether.

    it would be like a “registration is temporarily disabled” plugin.

    optionally, to be able to change the appearance/text on the registration page would be my next challenge. but one thing at a time.

    by the way, good work everyone!


    Sam Bauers
    Participant

    @sambauers

    The LDAP plugin has a feature that disables the registration page, you can make a simple plugin based on that.

    ALternatively you could run the restrict registration plugin and blacklist everything.

    right, i started by downloading the restrict registration plugin and trying to figure it out from there..

    i’ll take a look at the LDAP one too. thanks!

    also, it occured to me that there might be an option in the config.php for this but i double checked and there wasn’t. oh, well..

    i’ll see if i can figure it out.


    Sam Bauers
    Participant

    @sambauers

    I think you started with looking at the wrong plugin.

    I’ve got the code here if you want it, if you want a challenge, then *don’t* read on…:

    <?php
    /*
    Plugin Name: Disable registration
    Plugin URI:
    Description: Disables registration
    Author: Sam Bauers
    Version: 0.0.1
    Author URI:
    */

    add_action('bb_init', 'disable_registration');

    function disable_registration() {
    global $bb;
    if ($_SERVER['PHP_SELF'] == $bb->path . 'register.php') {
    bb_die(__('Registration is temporarily disabled for this forum.'));
    }
    }
    ?>

    Make a new file from this code and drop it into your plugins folder. You may need to add some values in the header part to allow it to be registered in the admin area.

    oops, i peeked..

    i found the function disableRegistration() in the LDAP plugin but i still hadn’t identified which part was doing what. anyways, it looks like bb_init is the hook that i was looking for! right on. oh, and do you mind if i end up using it as the starting point for writing my own plugin? i was hoping to eventually get it to work within my templates and easily customize the text that’s being displayed, etc. But, don’t tell me how to do that, i need the practice! besides, i’ll be around with more questions soon enough i’m sure..


    Sam Bauers
    Participant

    @sambauers

    > do you mind if i end up using it as the starting point for writing my own plugin?

    It’s GPL licensed, so if your plugin is GPL licensed, then that’s fine.

    cool. it will be. thanks again for the help. i’ll be watching the (unofficial) wiki!

    so here it is http://bbpulp.org

    Fantastic!

    What’s the pulp thing about, though? :P


    Sam Bauers
    Participant

    @sambauers

    Take your pick…

    pulp

    [noun]: a soft, wet, shapeless mass of material

    [noun]: a soft wet mass of fibers derived from rags or wood, used in papermaking.

    [usu. as adj. ]: popular or sensational writing that is generally regarded as being of poor quality

    … and it’s a synonym of “press”

    hey, i found this link: http://timjoh.com/list-of-bbpress-template-functions/ yesterday – which has a list of all the template functions (up to 0.8.1).

    i was going to use that as a reference until bbpulp had more info –

    but now i see that the wiki has already begun to fill out..

    i guess i’m still a little confused by all the terminology, perhaps someone could help me by distiguishing between the following terms:

    – template functions

    – pluggable functions

    – plugin functions

    – filters (defined earlier)

    – hooks / actions (defined earlier)

    maybe all this could be included on the wiki too?

    anyway, the list of template functions might help since i see that no link has been created yet for it under the heading: “Theming documentation” on bbpulp.

    came across this topic and bbpulp now goes to a porn site


    Olaf Lederer
    Participant

    @finalwebsites

    no that is link is Okay, but his server is hacked :)

Viewing 12 replies - 26 through 37 (of 37 total)
  • You must be logged in to reply to this topic.
Skip to toolbar