How do I render user Login block in main menu? I wrote the following code but I see only 'array' word.

function mytheme_menu_tree__primary(&amp;$variables) {
   return '&lt;ul class="menu nav navbar-nav"&gt;' . $variables['tree'] . module_invoke('user', 'block_view', 'login')['content']  
    . '&lt;/ul&gt;'; 

}
Block content can either be a string or a render array. As such you need to run it through render:

$block_content = module_invoke('user', 'block_view', 'login')['content'];
return '&lt;ul class="menu nav navbar-nav"&gt;' . $variables['tree'] . render($block_content) . '&lt;/ul&gt;'; 


It's worth bearing in mind that the user login form isn't wrapped in &lt;li&gt; tags, so unless you're altering the markup for that form elsewhere, your code will produce invalid markup.