gpt4 book ai didi

wordpress - 在 wp-admin 之后登录并重定向

转载 作者:行者123 更新时间:2023-12-02 22:19:00 25 4
gpt4 key购买 nike

这个想法可行吗?

如果管理员用户从 http://domain.ltd/wp-admin 登录 wp-admin 面板;我们可以重定向到一些外部页面吗 http://domain.ltd/my-newadmin ?这可能吗?

谢谢。

最佳答案

这可以使用过滤器 wp_login .在此示例中,如果用户具有 administrator 能力,则会发生重定向。

add_action( 'wp_login', 'so_14005301_redirect_admin_login', 10, 2 );

function so_14005301_redirect_admin_login( $user_login, $user )
{
if( array_key_exists( 'administrator', $user->caps ) )
{
wp_redirect( site_url( 'new-admin/', 'http' ), 301 );
exit;
}
}

代码引用:


变量引用:
函数回调接收到的$user参数内容:

WP_User Object
(
[data] => stdClass Object
(
[ID] => 1
[user_login] => my_name
[user_pass] => $P$BAdksWhVu4gZlZPZnv0m/VuUjsS3/Z0
[user_nicename] => my_name
[user_email] => email@gmail.com
[user_url] =>
[user_registered] => 2012-12-15 12:12:20
[user_activation_key] =>
[user_status] => 0
[display_name] => my_name
)

[ID] => 1
[caps] => Array
(
[administrator] => 1
)

[cap_key] => wp_capabilities
[roles] => Array
(
[0] => administrator
)

[allcaps] => Array
(
[switch_themes] => 1
[edit_themes] => 1
[activate_plugins] => 1
[edit_plugins] => 1
[edit_users] => 1
[edit_files] => 1
[manage_options] => 1
[moderate_comments] => 1
[manage_categories] => 1
[manage_links] => 1
[upload_files] => 1
[import] => 1
[unfiltered_html] => 1
[edit_posts] => 1
[edit_others_posts] => 1
[edit_published_posts] => 1
[publish_posts] => 1
[edit_pages] => 1
[read] => 1
[level_10] => 1
[level_9] => 1
[level_8] => 1
[level_7] => 1
[level_6] => 1
[level_5] => 1
[level_4] => 1
[level_3] => 1
[level_2] => 1
[level_1] => 1
[level_0] => 1
[edit_others_pages] => 1
[edit_published_pages] => 1
[publish_pages] => 1
[delete_pages] => 1
[delete_others_pages] => 1
[delete_published_pages] => 1
[delete_posts] => 1
[delete_others_posts] => 1
[delete_published_posts] => 1
[delete_private_posts] => 1
[edit_private_posts] => 1
[read_private_posts] => 1
[delete_private_pages] => 1
[edit_private_pages] => 1
[read_private_pages] => 1
[delete_users] => 1
[create_users] => 1
[unfiltered_upload] => 1
[edit_dashboard] => 1
[update_plugins] => 1
[delete_plugins] => 1
[install_plugins] => 1
[update_themes] => 1
[install_themes] => 1
[update_core] => 1
[list_users] => 1
[remove_users] => 1
[add_users] => 1
[promote_users] => 1
[edit_theme_options] => 1
[delete_themes] => 1
[export] => 1
[administrator] => 1
)

[filter] =>
)

关于wordpress - 在 wp-admin 之后登录并重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14005301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com