Skip to:
Content
Pages
Categories
Search
Top
Bottom

Correct way of initialize BuddyPress

  • @duduweiland

    Participant

    Hello,

    I’m developing BuddyPress XML-RPC Receiver plugin (http://github.com/duduweiland/buddypress-xmlrpc-receiver), but i’m stuck with a problem: initialize BuddyPress core and plugins.

    I was using `do_action( ‘bp_init’ )` but testing with some plugins it doesn’t works.

    Welcome Pack:
    `PHP Fatal error: Cannot redeclare class DP_Welcome_Pack_Admin in /var/www/html/blog/wp-content/plugins/welcome-pack/welcome-pack-admin.php on line 22`

    BP Webcam Avatar:
    `PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘bp_wa_setup_globals’ not found or invalid function name in /var/www/html/blog/wp-includes/plugin.php on line 406
    PHP Fatal error: Cannot redeclare wa_setup_globals() (previously declared in /var/www/html/blog/wp-content/plugins/bp-webcam-avatar/wa.php:4) in /var/www/html/blog/wp-content/plugins/bp-webcam-avatar/wa.php on line 11`

    BuddyPress Usernames Only:
    `PHP Fatal error: Cannot redeclare ray_bp_core_get_userlink() (previously declared in /var/www/html/blog/wp-content/plugins/buddypress-usernames-only/bp-usernames-only.php:10) in /var/www/html/blog/wp-content/plugins/buddypress-usernames-only/bp-usernames-only.php on line 16
    `

    I don’t know exactly what are these errors, but looks like some plugins are being loaded twice (I have a lot of others plugins here and they works just fine!)

    Anyone have any idea what it could be?

Viewing 4 replies - 1 through 4 (of 4 total)
  • @modemlooper

    Moderator

    If BP is active you do not need to re init. If it is active all it’s functions are available.

    @duduweiland

    Participant

    To be more precise, I need to access $bp->loggedin_user. If I do not run do_action(‘bp_init’) I get an object like this:

    `// not using do_action(‘bp_init’);
    var_dump($bp->loggedin_user);

    object(stdClass)#3391 (6) {
    [“id”]=>
    int(0)
    [“fullname”]=>
    bool(false)
    [“is_site_admin”]=>
    bool(false)
    [“is_super_admin”]=>
    bool(false)
    [“domain”]=>
    NULL
    [“userdata”]=>
    bool(false)
    }`

    But if I do run with do_action(‘bp_init’) I can get all the correct information, but if the plugins I mentioned are active I get also those errors!

    `do_action(‘bp_init’); // loggedin_user);

    object(stdClass)#3378 (6) {
    [“id”]=>
    int(1)
    [“fullname”]=>
    string(5) “admin”
    [“is_site_admin”]=>
    bool(true)
    [“is_super_admin”]=>
    bool(true)
    [“userdata”]=>
    object(stdClass)#3450 (10) {
    [“ID”]=>
    string(1) “1”
    [“user_login”]=>
    string(5) “admin”
    [“user_pass”]=>
    string(34) “__the_password_hash_here__”
    [“user_nicename”]=>
    string(5) “admin”
    [“user_email”]=>
    string(24) “admin @localhost
    [“user_url”]=>
    string(0) “”
    [“user_registered”]=>
    string(19) “2013-01-05 17:25:49”
    [“user_activation_key”]=>
    string(0) “”
    [“user_status”]=>
    string(1) “0”
    [“display_name”]=>
    string(5) “admin”
    }
    [“domain”]=>
    string(36) “http://localhost/blog/members/admin/”
    }`

    * I set the loggedin user with `wp_set_current_user( $userID )`

    @modemlooper

    Moderator

    Use globals to access bp

    `function my_get_logged_in() {
    global $bp;
    $user = $bp->loggedin_user;
    return $user;
    }`

    @chrisclayton

    Participant

    If you’re developing it on trunk (which you probably should be at this stage), you’ll also be able to use buddypress()->loggedin_user; instead of declaring globals everywhere.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Correct way of initialize BuddyPress’ is closed to new replies.
Skip to toolbar