2013-12-10 42 views
-1

我有一个名为编辑配置文件的页面,我已经安装了配置文件生成器插件,所以用户可以从前端编辑他们的配置文件,如果用户登录,我想显示编辑配置文件和注销链接,是登录。我怎么能做到这一点?我正在使用wp-bootstrap响应主题,我是wordpress开发中的新成员,请帮助我。我是否需要更改header.php文件中的任何内容?需要在登录用户wordpress的菜单中编辑个人资料链接?

<?php 
if (is_user_logged_in()) { 
    // i want to add Edit profile and logout to the menu 
} else { 
    // i want to add login to the menu 
} ?> 
+0

什么WordPress版本您使用的? – Matteo

+0

3.7.1和主题是wp-bootsstrap – Naveenbos

回答

1

可以使用wp_nav_menu_items过滤器添加菜单

add_filter('wp_nav_menu_items', 'your_custom_menu_item', 10, 2); 
function your_custom_menu_item ($items, $args) { 

if (is_user_logged_in()) { 
    $items .= '<a href="user profile link">Show whatever</a>'; 
} else { 
    $items .= '<a href="login link">Show whatever</a>'; 
} 

    return $items; /* This will have the menu items */ 
} 

Reference

+0

我想为此添加新菜单吗?我正在使用wp-bootssrtap插件 – Naveenbos

+0

我想你不需要添加新的菜单,我假设wp-bootssrtap插件已经实现了wordpress菜单,所以它将工作 –

+0

是我想添加此代码吗?在functions.php中? – Naveenbos

相关问题