You could try something like the code below.
<?php
/**
* Use the two lines below if the user_id is not available
* via get_current_user_id at this point in code execution.
*
* $user_id = apply_filters( 'determine_current_user', false );
* wp_set_current_user( $user_id );
*/
$current_user_id = get_current_user_id();
$user_data = get_userdata( $current_user_id );
$user_roles = $user_data->roles;
$link_path="";
if ( is_array( $user->roles ) ) {
// Look for desired role.
if ( in_array( 'subscriber', $user->roles ) ) {
// Create link based on role.
$link_path="subscriber_link";
} elseif ( in_array( 'editor', $user->roles ) ) {
// Create link based on role.
$link_path="editor_link";
} else {
// Create default link.
$link_path="default_link";
}
}
$link_to = esc_url( get_home_url( null, $link_path ) );
$logout_url = esc_url( wp_logout_url() );
?><?php if ( is_user_logged_in () ): ?>
<a href="<?php echo $link_to; ?>"><span class="wbutton">My Account</span></a> | <a href="<?php echo $logout_url; ?>"><span class="wbutton">Logout</span></a>
<?php else : ?>
<a href="/connect/"><span class="wbutton">Login | Register</span></a>
<?php endif; ?>