我当前正在使用网上论坛插件,我希望在创建新用户时将其自动分配给该网上论坛。 $ groupName打印出已登录用户的组(贡献者),并且当贡献者创建新用户(订户)时,订户应与贡献者具有相同的组。调试器正确显示了$ groupName,但是do_shortcode部分不起作用。你有什么主意吗?
add_action( 'user_register', array($this, 'create_user'), 10, 1 );
function create_user($user_id) {
global $wpdb;
//Get current user's group id from database
$getValue = $wpdb->get_results("SELECT user_id , wp_groups_group.group_id, wp_groups_user_group.group_id, name FROM wp_groups_group, wp_groups_user_group WHERE wp_groups_group.group_id = wp_groups_user_group.group_id");
$currentUser = wp_get_current_user();
$currentUserID = $currentUser->ID;
$groupID = "";
$groupName = "";
foreach ($getValue as $key => $value) {
if ($currentUserID == $value->user_id && $value->group_id > 1) {
$groupID = $value->group_id;
$groupName = $value->name;
}else{
}
}
do_shortcode('[groups_join group="'.$groupName.'"]');
}