使用 get_currentuserinfo(); 函数:
<?php
echo json_encode(get_currentuserinfo());
?>
输出结果:
{
"data": {
"ID": "1",
"user_login": "fewfwe",
"user_pass": "fefvcvdgdsfdsf",
"user_nicename": "vgwefwef",
"user_email": "1344694396@qq.com",
"user_url": "",
"user_registered": "2020-10-03 15:59:04",
"user_activation_key": "vwefewfecxccw",
"user_status": "0",
"display_name": "zhufenghua",
"spam": "0",
"deleted": "0"
},
"ID": 1,
"caps": {
"administrator": true
},
"cap_key": "wp_capabilities",
"roles": [
"administrator"
],
"allcaps": {
"switch_themes": true,
"edit_themes": true,
"activate_plugins": true,
"edit_plugins": true,
"edit_users": true,
"edit_files": true,
"manage_options": true,
"moderate_comments": true,
"manage_categories": true,
"manage_links": true,
"upload_files": true,
"import": true,
"unfiltered_html": true,
"edit_posts": true,
"edit_others_posts": true,
"edit_published_posts": true,
"publish_posts": true,
"edit_pages": true,
"read": true,
"level_10": true,
"level_9": true,
"level_8": true,
"level_7": true,
"level_6": true,
"level_5": true,
"level_4": true,
"level_3": true,
"level_2": true,
"level_1": true,
"level_0": true,
"edit_others_pages": true,
"edit_published_pages": true,
"publish_pages": true,
"delete_pages": true,
"delete_others_pages": true,
"delete_published_pages": true,
"delete_posts": true,
"delete_others_posts": true,
"delete_published_posts": true,
"delete_private_posts": true,
"edit_private_posts": true,
"read_private_posts": true,
"delete_private_pages": true,
"edit_private_pages": true,
"read_private_pages": true,
"delete_users": true,
"create_users": true,
"unfiltered_upload": true,
"edit_dashboard": true,
"update_plugins": true,
"delete_plugins": true,
"install_plugins": true,
"update_themes": true,
"install_themes": true,
"update_core": true,
"list_users": true,
"remove_users": true,
"promote_users": true,
"edit_theme_options": true,
"delete_themes": true,
"export": true,
"aioseo_manage_seo": true,
"aioseo_setup_wizard": true,
"aioseo_general_settings": true,
"aioseo_search_appearance_settings": true,
"aioseo_social_networks_settings": true,
"aioseo_sitemap_settings": true,
"aioseo_internal_links_settings": true,
"aioseo_redirects_settings": true,
"aioseo_seo_analysis_settings": true,
"aioseo_tools_settings": true,
"aioseo_feature_manager_settings": true,
"aioseo_page_analysis": true,
"aioseo_page_general_settings": true,
"aioseo_page_advanced_settings": true,
"aioseo_page_schema_settings": true,
"aioseo_page_social_settings": true,
"aioseo_local_seo_settings": true,
"aioseo_about_us_page": true,
"aioseo_admin": true,
"rank_math_edit_htaccess": true,
"rank_math_titles": true,
"rank_math_general": true,
"rank_math_sitemap": true,
"rank_math_404_monitor": true,
"rank_math_link_builder": true,
"rank_math_redirections": true,
"rank_math_role_manager": true,
"rank_math_analytics": true,
"rank_math_site_analysis": true,
"rank_math_onpage_analysis": true,
"rank_math_onpage_general": true,
"rank_math_onpage_advanced": true,
"rank_math_onpage_snippet": true,
"rank_math_onpage_social": true,
"rank_math_admin_bar": true,
"manage_downloads": true,
"dlm_manage_logs": true,
"dlm_view_reports": true,
"administrator": true
},
"filter": null
}
使用 wp_get_current_user() 函数
这个函数,和上面效果是一样的。
{
"data": {
"ID": "1",
"user_login": "fefef",
"user_pass": "xfwfewf.",
"user_nicename": "zhufenghua",
"user_email": "vwefewf",
"user_url": "",
"user_registered": "2020-10-03 15:59:04",
"user_activation_key": "fwefcvde",
"user_status": "0",
"display_name": "fwefef",
"spam": "0",
"deleted": "0"
},
"ID": 1,
"caps": {
"administrator": true
},
"cap_key": "wp_capabilities",
"roles": [
"administrator"
],
"allcaps": {
"switch_themes": true,
"edit_themes": true,
"activate_plugins": true,
"edit_plugins": true,
"edit_users": true,
"edit_files": true,
"manage_options": true,
"moderate_comments": true,
"manage_categories": true,
"manage_links": true,
"upload_files": true,
"import": true,
"unfiltered_html": true,
"edit_posts": true,
"edit_others_posts": true,
"edit_published_posts": true,
"publish_posts": true,
"edit_pages": true,
"read": true,
"level_10": true,
"level_9": true,
"level_8": true,
"level_7": true,
"level_6": true,
"level_5": true,
"level_4": true,
"level_3": true,
"level_2": true,
"level_1": true,
"level_0": true,
"edit_others_pages": true,
"edit_published_pages": true,
"publish_pages": true,
"delete_pages": true,
"delete_others_pages": true,
"delete_published_pages": true,
"delete_posts": true,
"delete_others_posts": true,
"delete_published_posts": true,
"delete_private_posts": true,
"edit_private_posts": true,
"read_private_posts": true,
"delete_private_pages": true,
"edit_private_pages": true,
"read_private_pages": true,
"delete_users": true,
"create_users": true,
"unfiltered_upload": true,
"edit_dashboard": true,
"update_plugins": true,
"delete_plugins": true,
"install_plugins": true,
"update_themes": true,
"install_themes": true,
"update_core": true,
"list_users": true,
"remove_users": true,
"promote_users": true,
"edit_theme_options": true,
"delete_themes": true,
"export": true,
"aioseo_manage_seo": true,
"aioseo_setup_wizard": true,
"aioseo_general_settings": true,
"aioseo_search_appearance_settings": true,
"aioseo_social_networks_settings": true,
"aioseo_sitemap_settings": true,
"aioseo_internal_links_settings": true,
"aioseo_redirects_settings": true,
"aioseo_seo_analysis_settings": true,
"aioseo_tools_settings": true,
"aioseo_feature_manager_settings": true,
"aioseo_page_analysis": true,
"aioseo_page_general_settings": true,
"aioseo_page_advanced_settings": true,
"aioseo_page_schema_settings": true,
"aioseo_page_social_settings": true,
"aioseo_local_seo_settings": true,
"aioseo_about_us_page": true,
"aioseo_admin": true,
"rank_math_edit_htaccess": true,
"rank_math_titles": true,
"rank_math_general": true,
"rank_math_sitemap": true,
"rank_math_404_monitor": true,
"rank_math_link_builder": true,
"rank_math_redirections": true,
"rank_math_role_manager": true,
"rank_math_analytics": true,
"rank_math_site_analysis": true,
"rank_math_onpage_analysis": true,
"rank_math_onpage_general": true,
"rank_math_onpage_advanced": true,
"rank_math_onpage_snippet": true,
"rank_math_onpage_social": true,
"rank_math_admin_bar": true,
"manage_downloads": true,
"dlm_manage_logs": true,
"dlm_view_reports": true,
"administrator": true
},
"filter": null
}
本篇完,还有疑问?留下评论吧