我正在尝试显示此元数据:
public static function user_register($user_id) {
//The user_id is grabbed from wordpress and this is run after user
//registration, echo does display correctly the user_id as 806 (example)
//$data = empty.. which makes no sense!!
$data = get_user_meta ( $user_id , 'business', true );
//Everything undernearth runs as it should..
$grID = $wpdb->get_var("SELECT group_id FROM wp_groups_group WHERE name = '$data'");
Groups_User_Group::create( array( 'user_id' => $user_id, 'group_id' => $grID ));
}
一些确认:
是!设置变量$data = "806";
确实可以修复它!
然而,此变量发生变化......我不能为此设置静态字符串(806)。它必须是当前用户
数据库是正确的,有一个商业元和值设置(数据库似乎也很好)
user_id == 806
(通过以下测试确认)
public static function user_register( $user_id ) {
if($user_id == 806){
$data = "806";
}
$grID = $wpdb->get_var("SELECT group_id FROM wp_groups_group WHERE name = '$data'");
Groups_User_Group::create( array( 'user_id' => $user_id, 'group_id' => $grID ));
}
我尝试将$data
替换为:
$data = get_user_meta ( get_current_user_id() , 'business', true );
和
$usr = get_current_user_id();
$data = get_user_meta ( $usr , 'business', true );