Yes, this is similar to Can you put PHP inside PHP with echo?, but not identical and I would like to actually find a solution or a way to accomplish this.
Surely, there must be a way to show content to specific user groups within a template...
I have a wordpress menu that I'd like to only display to users with a set role.
I use this code to display my menu:
<?php wp_nav_menu( array( 'theme_location' => 'max_mega_menu_1' ) ); ?>
But the problem is that I need to use a snippet like the one below to execute opening and closing shortcodes to hide the menu from everyone else:
<?php
$menu = "my menu code here";
echo do_shortcode("[um_show_content roles='um_efa-pack'] ". $menu ." [/um_show_content]");
?>
How can I come up with a way of getting my original menu code within that PHP variable? I've been looking, but I can't find a good solution and I'm not even sure what to search for anymore.
If it helps, there is also a shortcode for the menu, but that would also require PHP to execute, no?
[maxmegamenu location=max_mega_menu_1]