Skip to:
Content
Pages
Categories
Search
Top
Bottom

how to invoke bbpress from a bp plugin? (for $bbdb settings and meta options)

  • another bbpress question :-P

    ok, I’m converting some of _ck_’s bbpress plugins to work from within group forums on the bp side (which work fine with a few updated filter calls – at least for sigs and bbcode)

    But I also run an external install of bbpress and would like to share the options stored in the bb meta table. So I need a reference to $bbdb->meta from a buddypress plugin. After looking over bp-forums-bbpress.php seems it is doable but…

    I’ve tried calling do_action( 'bbpress_init') but that gives me a blank page of death – also require_once( $bp->forums->bbconfig ) somehow wipes out the $bbdb global and causing BP to install bbpress with no prefix table names.

Viewing 10 replies - 1 through 10 (of 10 total)

  • r-a-y
    Keymaster

    @r-a-y

    You shouldn’t need to require anything since BP already loads it (if you have forums enabled).

    You should be able to just grab the meta using one of the bbPress meta calls.

    eg.

    bb_get_postmeta(bp_get_the_topic_post_id(), $cachekey)

    Make sure when grabbing the meta that you do a check to see if you’re on a forum post.

    do_action( 'bbpress_init' );

    This triggers BuddyPress to load the bbPress code. So as you’ve done, you need to call this early on. If it’s giving you the WSOD, you need to find out why and fix that.

    that was my first thought but bb_get_option and other functions are not defined if i’m trying to update some bb_option metadata from the bp dashboard side.

    @DJPaul – probably my problem – i’ve tried so many hooks, so i’ll try and start over tonight.


    Boone Gorges
    Keymaster

    @boonebgorges

    etiviti – Does your external installation of bbPress store data in the same database as your buddypress install? If not I think you will need a new $wpdb class in order to specify the right database creds.

    yep!, same database.

    ok, so i narrowed the issue down to just /wp-admin/ only

    function bp_forums_extras_setup_globals() {
    do_action( 'bbpress_init');
    }
    add_action( 'bp_init', 'bp_forums_extras_setup_globals');

    if i comment out do_action then /wp-admin/ loads up – otherwise WSOD. The action completes (calls function bp_forums_load_bbpress() ) but I guess something within WP conflicts?

    sorry for the triple post but found the root problem.

    Fatal error: Cannot redeclare checked() (previously declared in D:xampplitehtdocsbuddypresswp-contentpluginsbuddypressbp-forumsbbpressbb-adminincludesfunctions.bb-admin.php:1261) in D:xampplitehtdocsbuddypresswp-adminincludestemplate.php on line 387

    and the fix…

    function adminfix_adminfix_bbpress_init() {
    global $bbdb, $bb_roles, $wp_roles;

    if ( is_object( $bbdb ) && is_object( $bb_roles ) ) {
    return;
    }
    if ( is_object( $bbdb ) ) {
    $bb_roles =& $wp_roles;
    bb_init_roles( $bb_roles );
    return;
    }

    do_action( 'bbpress_init');

    }

    function bp_forums_extras_setup_globals() {

    adminfix_adminfix_bbpress_init();

    do_action('bp_forums_extras_init');

    }

    if (WP_ADMIN) {
    add_action( 'admin_init', 'bp_forums_extras_setup_globals', 500 );
    } else {
    add_action( 'bp_init', 'bp_forums_extras_setup_globals', 5 );
    }


    stwc
    Participant

    @stwc

    Looking forward to your bbpress plugin ports! I tried doing it myself and soon ran up against my nearly complete lack of PHP skills…. ;-)

    Again: look in your logsand find out why the add_action is failing. That’s what you need to fix.

    figured it out (see post above) – some reason in wp-admin mode $bb_roles was getting wiped

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘how to invoke bbpress from a bp plugin? (for $bbdb settings and meta options)’ is closed to new replies.
Skip to toolbar