• Resolved itskev

    (@itskev)


    In my sidebar widget, I have removed all links to user dashboard, edit profile, etc. I would love to auto-populate the user’s name with having a link to their profile. Any way to do this? I’ve been digging through the docs, but can’t find this particular need I have. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    Using our existing example:

    
    function filter_tml_widget_user_links( $links ) {
    	$user = wp_get_current_user();
    
    	$role = reset( $user->roles );
    	if ( empty( $role ) ) {
    		$role = 'subscriber';
    	}
    	if ( is_super_admin() ) {
    		$role = 'administrator';
    	}
    
    	// These links are for authors, editors and admins
    	if ( in_array( $role, array( 'author', 'editor', 'administrator' ) ) ) {
    		$links = array(
    			'dashboard' => array(
    				'title' => __( 'Dashboard' ),
    				'url'   => admin_url(),
    			),
    			'profile'   => array(
    				'title' => $user->display_name,
    				'url'   => admin_url( 'profile.php' ),
    			),
    			'logout'    => array(
    				'title' => __( 'Log Out' ),
    				'url'   => wp_logout_url(),
    			),
    		);
    
    	// These are for all other roles
    	} else {
    		$links = array(
    			'profile'   => array(
    				'title' => $user->display_name,
    				'url'   => admin_url( 'profile.php' ),
    			),
    			'logout'    => array(
    				'title' => __( 'Log Out' ),
    				'url'   => wp_logout_url(),
    			),
    		);
    	}
    
    	return $links;
    }
    add_filter( 'tml_widget_user_links', 'filter_tml_widget_user_links' );
    
    Thread Starter itskev

    (@itskev)

    Thanks Jeff. I have this and have edited it to remove some of the info, but how can I auto-populate the user’s name with no link to their profile?

    I’m still getting my feet wet with this php code.

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Where?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Show Username without Link’ is closed to new replies.