请尝试以下代码:
// Set up the global variables
$user_id;
$loc_status;
// When the user login, setup all variables that you need
function get_user_informations( $redirect_to, $request, $user ) {
//is there a user to check?
if ( $user ) {
$user_id = $user->id;
$loc_statuss = $wpdb->get_row( "SELECT status FROM profile_location INNER JOIN relation_user ON profile_location.loc_id=relation_user.loc_id WHERE relation_user.user_id=".$user_id );
$loc_status = $loc_statuss->status;
}
}
add_filter( \'login_redirect\', \'get_user_informations\', 10, 3 );
更多关于
login_redirect
在
Docs.