I would imagine that since no one answered the first time, you won’t get much more on a duplicate type thread…..
Trent
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.
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?
Well, it turns out I shouldn’t play with bbpress/wpmu when I’m tired at 2am. I never ended up activating the plugin . 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: https://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’);
?>
causes a fatal error and then lots of errors when i go to log out