You can use the bloginfo( 'name' )
function to display the site name. Information about the current logged in user can be retrieved using the get_currentuserinfo()
function.
Here is the fixed code:
function my_network_notice(){
global $pagenow, $currentuser;
get_currentuserinfo();
if ( $pagenow == 'index.php') : ?>
<div id="secondaryBox">
<div id="author">
<img src="https://wordpress.stackexchange.com/questions/77448/<?php echo get_stylesheet_directory_uri(); ?>/img/btn-articles-admin.png" width="40px" height="40px" />
<h5><?php echo esc_html( $current_user->display_name ); ?></h5>
<h6><?php echo esc_html( translate_user_role( $current_user->roles[0] ) ); ?>, <?php bloginfo( 'name' ); ?></h6>
</div>
</div>
<?php endif;
}
add_action( 'admin_notices', 'my_network_notice' );
However, at the moment you’re just outputting the data straight to the dashboard. It would be better to create a dashboard widget (like the Right Now or Recent Drafts dashboard widgets):
/* display the dashboard widget output */
function wpse_77452_dashboard_widget_output() {
global $currentuser;
get_currentuserinfo(); ?>
<div id="secondaryBox">
<div id="author">
<img src="https://wordpress.stackexchange.com/questions/77448/<?php echo get_stylesheet_directory_uri(); ?>/img/btn-articles-admin.png" width="40px" height="40px" />
<h5><?php echo esc_html( $current_user->display_name ); ?></h5>
<h6><?php echo esc_html( $current_user->roles[0] ); ?>, <?php bloginfo( 'name' ); ?></h6>
</div>
</div>
<?php
}
/* add the dashboard widget */
function wpse_77452_add_dashboard_widgets() {
wp_add_dashboard_widget(
'network_notice', // ID of widget
'Important Information', // title of widget
'wpse_77452_dashboard_widget_output' // function used to display widget
);
}
add_action( 'wp_dashboard_setup', 'add_notice_dashboard_widgets' );