登录时如何从Wordpress用户表中获取当前用户ID

时间:2019-06-28 13:37:55

标签: php wordpress

我想在登录时将用户数据存储到自定义表中,所以我必须从wordpress用户表中获取用户ID

我尝试过@Binds @Named(Constants.API_URL_KEY) abstract fun provideApiUrl(apiUrl: String): String @Binds @Named(Constants.SOCKET_URL_KEY) abstract fun provideSocketUrl(socketUrl: String): String ,但它总是返回public class WebSocketConnectionManager extends ConnectionManagerSupport { private final WebSocketClient client; private final WebSocketHandler webSocketHandler; @Getter @Nullable private WebSocketSession webSocketSession;

1 个答案:

答案 0 :(得分:0)

将其写入html中,您将获得当前的用户ID

<?php 
global $current_user;
wp_get_current_user();
//if you want another thing like his name or any things
print_r($current_user);
//if you want ID
?>
<h1><?php echo $current_user->ID;?></h1>