Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbpress + wpmu user registration default role


  • neyoung
    Member

    @neyoung

    As everyone knows, if a user registers in bbpress instead of through wordpress(mu) that user doesn’t get a default role set.

    I’ve dug and dug on both the bbpress and wpmu forums and haven’t found a fix for this. I did find a fix that apparently works for wordpress, but I tried it for wordpress mu with no luck.

    The 4th post in this thread explains a way to set roles in wordpress mu.

    I imagine that a plugin with the combination of the two solutions would allow users to register through bbpress and get a default role on the main wordpress mu blog. But, unfortunately I have no clue what I’m doing. If anyone has a free minute or two to look at the bits of code and maybe hack something together that would be awesome.

    Oh, and I’m using the latest versions of both bbpress and wpmu.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I would imagine that since no one answered the first time, you won’t get much more on a duplicate type thread…..

    Trent


    neyoung
    Member

    @neyoung

    Sorry for the duplicate post, I think I was tired when I posted the other one and I’d sort of forgot about it.

    Anyways, I’ve been playing with the two bits of code and I think I’ve ‘almost’ got it working. If I execute Detectives query manually from the terminal it works, but for some reason when I put it all in a little plugin nothing happens. Is there a type-o or a noob error somewhere?

    `<?php

    /*

    Plugin Name: bbpress wpmu default role

    */

    function trk_addDefaultRole($user_id) {

    global $bbdb;

    $bbdb->query(“INSERT INTO wp_usermeta ( user_id, meta_key, meta_value ) VALUES ( ‘$user_id’, ‘wp_1_capabilities’, ‘a:1:{s:10:”subscriber”;b:1;}’ )”);

    }

    add_action(‘bb_new_user’, ‘trk_addDefaultRole’);

    ?>

    I don’t know why nothing would happen, but I’d advise you to use the API instead of a db query. If μ isn’t already loaded when you load bb, it might be good to load it when someone registers and use a μ function to set their role instead.


    neyoung
    Member

    @neyoung

    I’ve got μ loaded through the config.php file. I’ll look into some of the μ functions and see what I can do.

    I don’t think that trk_addDefaultRole function is being called from bb_new_user at all. Is there a way I can test to see if it is?


    neyoung
    Member

    @neyoung

    Well, it turns out I shouldn’t play with bbpress/wpmu when I’m tired at 2am. I never ended up activating the plugin o.O . Anyways, I got the code that Detective wrote to work once I pulled my head outta my butt!

    Here’s for anyone else that has this problem…

    toss this into a file called default-role.php and put it in your my-plugins directory within your bbpress install folder.

    <?php

    /*

    Plugin Name: bbpress wpmu default role

    Plugin URI: http://bbpress.org/forums/topic/yet-another-integration-bug-no-role-set-on-registration?replies=5

    Description: Sets a default WPMU role for all new bbpress users.

    Author: Detective

    Author URI: http://www.ryuuko.cl/

    */

    function wpbb_add_user_role_rk($user_id) {

    $user = new WP_User($user_id);

    $user->set_role(get_option(‘default_role’));

    }

    add_action( ‘bb_new_user’, ‘wpbb_add_user_role_rk’);

    ?>


    joetwostep
    Member

    @joetwostep

    causes a fatal error and then lots of errors when i go to log out

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

You must be logged in to reply to this topic.