简体   繁体   English

WordPress-检查是否使用javascript登录为管理员

[英]Wordpress - Check if logged as admin with javascript

I'm using wordpress and this plugin: https://wordpress.org/plugins/tp-navigation-menu/ I've modified the number of top pixel from 0 to 26: 我正在使用wordpress和此插件: https : //wordpress.org/plugins/tp-navigation-menu/我已经将顶部像素的数量从0修改为26:

jQuery('#navbar').css({ 'position': 'fixed', 'top':26 });}

but if I am logged in as admin appears the wpadminbar that spoils everything! 但是,如果我以admin身份登录,则会出现wpadminbar,破坏一切! The menu goes below that bar. 菜单在该条下方。 How can I solve this problem? 我怎么解决这个问题? I imagine I could check if i'm logged top is 56 otherwise 26, but how can i know this? 我想我可以检查是否登录的前56位是26,但是我怎么知道呢?

You can hook this line in your functions.php 您可以将此行钩在您的functions.php中

add_filter('show_admin_bar', '__return_false'); add_filter('show_admin_bar','__return_false');

You can also use this line to specify the user. 您也可以使用此行指定用户。

if (!current_user_can('edit_posts')) { show_admin_bar(false); 如果(!current_user_can('edit_posts')){show_admin_bar(false); } }

The below code will help you 下面的代码将帮助您

  show_admin_bar(false);

Put the above line in functions.php in theme file. 将以上行放在主题文件中的functions.php中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM