2013-12-10 46 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

相關問題