Creating a dynamic link to "home" for site admins

Hi,

I wanted to create a link for subsite admins that would redirect them to their individual home pages… link to be created on a static front end page.

I followed some of the steps from this post, but instead of using a template, I created shortcode and added it to a specific page.

https://premium.wpmudev.org/forums/topic/how-do-i-create-a-dynamic-home-page-link

However, the code doesn’t seem to work.. nothing actually appears on the page. I added he following to my childs function.php, but nothing. I added another simple shortcode that I created to display hello world, and that works fine. So i’m not sure where the problem is… i suspect that the blogid is not being retrieved properly?? Is there anything I can add to this snippet of code that might help me figure out what its doing or not doing?

here’s the code snippet:

function showhomeshortcode() {

global $user;
$blogs = get_blogs_of_user( $user->ID, true );
if ( is_array( $blogs ) ) {
foreach ( (array) $blogs as $key => $val ) {
if( $val->userblog_id != 1 ) {
echo ' <a class="' . $class . '" href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'Home' ) . '</a> ';
break;
}
}
}

}
add_shortcode('showhome', 'showhomeshortcode');

thanks!

Shayne