I am trying to get this meta data to display:
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 ));
}
Some confirmations:
Yes! setting variable $data = "806";
does fix it!
However, this variable changes... I can't have a static string (806) for this. It has to be the current user.
The database is correct, there is a meta for business and the value is set (DB also seems to be fine)
user_id == 806
(confirmed with testing below)
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 ));
}
Other scripts that I have tried replacing $data
with:
$data = get_user_meta ( get_current_user_id() , 'business', true );
and
$usr = get_current_user_id();
$data = get_user_meta ( $usr , 'business', true );