Title: PHP code re profile in menu
Last modified: September 30, 2016

---

# PHP code re profile in menu

 *  [Don46](https://wordpress.org/support/users/don46/)
 * (@don46)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/php-code-re-profile-in-menu/)
 * I posted this request in BBpress forum but for some reason it did not show up
   so I hope someone here can help as it is more a wordpress issue and my understanding
   of PHP code!
    WP 4.6 BBpress plugin 2.5.10 I am using some of the super BBpress
   code suggestions at [https://codex.bbpress.org/layout-and-functionality-examples-you-can-use/](https://codex.bbpress.org/layout-and-functionality-examples-you-can-use/)
   and most work just fine ‘out of the box’ but I am not sure what I should be putting
   in place of ‘ my_nav_menu_profile_link’ in this one. If I put in the code as 
   is….
 *     ```
       // Filter wp_nav_menu() to add profile link
       add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
       function my_nav_menu_profile_link($menu) {
           if (!is_user_logged_in())
               return $menu;
           else
               $current_user = wp_get_current_user();
               $user=$current_user->user_nicename ;
               $profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';
               $menu = $menu . $profilelink;
               return $menu;
         
       }
       ```
   
 * I get this when trying the menu link……
    Object not found! The requested URL was
   not found on this server. The link on the referring page seems to be wrong or
   outdated. Please inform the author of that page about the error. If you think
   this is a server error, please contact the webmaster. Error 404 localhost Apache/
   2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.24
 * If I replace the ‘ my_nav_menu_profile_link’ with the actual link like this…..
 *     ```
       /* Profile link in menu....................*/
       // Filter wp_nav_menu() to add profile link
       add_filter( 'wp_nav_menu_items', 'http://localhost/wordpress/wp-admin/profile.php' );
       function http://localhost/wordpress/wp-admin/profile.php($menu) {
           if (!is_user_logged_in())
               return $menu;
           else
               $current_user = wp_get_current_user();
               $user=$current_user->user_nicename ;
               $profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';
               $menu = $menu . $profilelink;
               return $menu;
   
       }
       ```
   
 * I get this as soon as I go to the site…
 * Parse error: syntax error, unexpected ‘:’, expecting ‘(‘ in C:\xampp\htdocs\wordpress\
   wp-content\themes\twentytenchild\functions.php on line 49
    What should I be entering
   and when I move to a live site will it need to be further changed?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Stephen Edgar](https://wordpress.org/support/users/netweb/)
 * (@netweb)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/php-code-re-profile-in-menu/#post-8238421)
 * I’ve just approved the bbPress post, it got picked up by our filters:
 * [https://bbpress.org/forums/topic/profile-in-menu-php/](https://bbpress.org/forums/topic/profile-in-menu-php/)
    -  This reply was modified 9 years, 3 months ago by [Stephen Edgar](https://wordpress.org/support/users/netweb/).
 *  Thread Starter [Don46](https://wordpress.org/support/users/don46/)
 * (@don46)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/php-code-re-profile-in-menu/#post-8244759)
 * Thanks Stephen
    I dont know what is going on with the BBpress forum but I just
   received a notification of another user (having similar problems) who posted 
   a reply to this thread (in the BBpress forum) and upon clicking on the link provided
   the post did NOT show his reply either? We both would appreciate a solution to
   what is, I am sure, just due to our ignorance of PHP code be it within BBpres
   or WordPress child themes! Perhaps in the meanwhile there is an ongoing problem
   with posting over there?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP code re profile in menu’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Stephen Edgar](https://wordpress.org/support/users/netweb/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/php-code-re-profile-in-menu/#post-8238421)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
