Forums

Join
bbPress Support ForumsPluginsHooks & Filters Docu

Info

Hooks & Filters Docu

  1. 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!

  2. Nice we also need a list of available APIs :)

  3. I would like that as well Null! I changed the title to be more clear! Hope you don't mind!

    Trent

  4. It's not actually meant to be instructions, more like a list of hooks and filters Trent. I just included that as an aside for someone starting out.
    I'm sure you two have seen some more filters or hooks yourself, so help out and add them please. The point is, rather than waiting around for documentation, start getting some makeshift documentation up ourselves.

    post_text is a filter called on the text leaving the database I think, it's what the emoticons use.

  5. Although this topic is a noble idea, I can't see it having enough structure to be really useful.

    I've started a conversation about creating a wiki for this sort of thing on the dev list. I think that would be optimal and more easily maintained.

    I'd be happy to start one, but I think it would be better coming directly out of Automattic.

  6. Fair enough ;)

    Trent

  7. @Sam - We talked about this documentation on the bbdevlist before and Matt wanted to lean towards the release of a major release of bbPress before any real start to avoid massive changes to the documentation, so here we sit *sigh*

    Trent

  8. Walks by and sees Trent sitting.... Heya Trent, want some company?

  9. So you guys wanna keep sitting or anyone fancy not waiting around for however long?

  10. It's out of our hands, come sit with us, silent demonstration :D

  11. It's not really out of our hands. We could do something.

  12. Yes, we could set up a wiki - but to avoid (most of) the stated problem it would have to be a technical/developers wiki for now. We should also agree to move it's contents to any official wiki when it comes along. I assume that an official wiki would use the same software as codex.wordpress.org which appears to be mediawiki, so to be compatible when the time comes we would have to use that too. My personal thought is that it is about time for this, and as the development community grows it is becoming necessary. I could set one up in half an hour (I'd be happy to host it - ad free). And we could work out the taxonomy of it here.

    To be slightly democratic, I say if ten people who we recognise as regulars/developers vote for it here, then we should go ahead. I'm also willing to hear arguments against the idea too.

    Should we vote on it?

  13. Set it up sam!

    For now we need some stuff about:

    Installation
    WP intergrating
    API's
    Hooks
    Filters
    Plugins
    Templates/themes

    Did I forget something?

  14. I don't know if recognised or not, but I'm all for it.

  15. I don't know if I count as recognised or regular? Does it help if I remove my disguise?

    I'm all for some docs, even if it's just a bare-bones list of available hooks and filters.

  16. @Null: perhaps not installation and WP integrating as I don't want to duplicate existing docs on this site and I think we should stick to developer docs for now - primarily to help plugin developers. The others seem like sound start to the categories though.

  17. Well lets start a wii thingy now with a list of:
    API's
    Hooks
    Filters

    And with what they do/can be used for...?

  18. Anyone got a good domain name suggestion? I've got a domain name registration credit at my host which I can use.

  19. bbwiki.com is taken, but http://www.bbreference.com is not. If it's understandable it doesn't matter that much anyway. :)

  20. bbdocs.com?

  21. I still think that codex.bbpress.org is still the best though to avoid confusion and keep the same design. Someone send something in the developer list again for some 'more pointed' discussion on this.

    Trent

  22. Ditto on the subdomain of bbpress.org.

  23. Didn't you say there will be no Automattic documentation before 1.0 release? Obviously codex.bbpress.org is the best, but that would be official ... and we haven't got official.

  24. We should assume that codex.bbpress.org is out of the question for now, even though the content that we generate may end up there.

    How about bbpulp.org ?

  25. quote: How about bbpulp.org ?

    I love it :D

  26. > I love it :D

    So do I, so here it is http://bbpulp.org

    Registration required to contribute.

    All articles to be submitted under the GPL Free Documentation License.

  27. 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!

  28. 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.

  29. 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.

  30. 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.