I am working on a wordpress network and I am trying to figure out how to create a if/else link that will take the current user from the main site to a specific page on their blog. For example in theory this is what I am trying to achieve –
<?php global $wp_roles;
foreach ( $wp_roles->role_names as $role => $name ) :
if (current_user_can( $role ) && $role == 'HAS A BLOG') { ?>
<a href="<?php URL TO USERS BLOG ?>/SPECIFIC-PAGE/">A Page on your blog</a>
<?php } else { ?>
<a href="HOME">MAIN SITE</a>
I found some info on something similar but I could not get it to work for me at all – link
How can I go about getting this to work? Any help would be appreciated. Thanks.
Ok I was able to achieve what I want by using the following code –