How to add php to custom link in the nav menu? [closed]

You could do something like this:

<?php
if ( is_user_logged_in() ) {
     wp_nav_menu( array( 'theme_location' => 'logged-in-menu' ) );
} else {
     wp_nav_menu( array( 'theme_location' => 'logged-out-menu' ) );
}
?>

EDIT:

Here is another try, same theory but different execution:

if ( is_user_logged_in() )
{ 
    // Filter wp_nav_menu() to add additional links and other output
    function new_nav_menu_items($items) 
    {
        $homelink = '&lt;li class=&quot;home&quot;&gt;&lt;a href=&quot;' . bp_loggedin_user_domain() . '&quot;&gt;' . __('Profile') . '&lt;/a&gt;&lt;/li&gt;';
        $items = $homelink . $items;
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
}