Here’s what I have so far as my notification, but I can’t find any information around how to input the user’s name, role and site name within those sections. You can see where they are supposed to go. Any help would be much appreciated as I’ve been stumped for a few days now…
function my_network_notice(){
global $pagenow;
if ( $pagenow == 'index.php') {
echo '<div id="secondaryBox">
<div id="author">
<img src="/wp-content/themes/dewslyWeb/img/btn-articles-admin.png" width="40px" height="40px" />
<h5>[DISPLAYNAMEHERE]</h5>
<h6>[USERROLEHERE], [SITENAMEHERE]</h6>
</div>
</div>
}
}
add_action('admin_notices', 'my_network_notice');
You can use the
bloginfo( 'name' )
function to display the site name. Information about the current logged in user can be retrieved using theget_currentuserinfo()
function.Here is the fixed code:
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):
You should wait for
'load-index.php'
and not add the function to alladmin_notices
. The rest is simple:Caveat: One user can have multiple roles.
$user->roles[0]
is a dirty hack, you should check the length of this array.First you need to get the current user data (Logged in). http://codex.wordpress.org/Function_Reference/get_currentuserinfo
The you need to get_blogs_of_user.. I only display one now for you. If you want all you need a foreach loop for that. See in codex.