I am using Theme My Login plugin for a WordPress website.  The website needed a login in order to access a private store configuration of WooCommerce.  I used the shortcode configuration of Theme My Login to add the login form to the home page.  I used the Redirection extension to have the login result go back to the home page to cause the hidden menu items to appear.   However, the login form was still and caused confusion.

I then found out Theme My Login had a widget.  One of the benefit was the widget would automatically change once logged in.   So, much better implementation of the login experience.  However, the default showed the a simple title, a register link and user icon.

I did some search of the documentation and learned this is called the User Panel.  I was able to modify it using the code.  This code actually need to be put in a file called “theme-my-login-custom.php” which is stored in /wp-content/plugins/.  Beside the code below, the command “<?php” needed to be added at the tope of the file.  Here is the code.

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’ => __( ‘Profile’ ),
‘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’ => __( ‘Profile’ ),
//            ‘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’ );

 

Next, I wanted to remove the user icon.   I emailed the plugin developer and got back this code.

function hide_tml_avatar( $size ) {
return 0;
}
add_filter( ‘tml_widget_avatar_size’, ‘hide_tml_avatar’ );

 

Finally, I wanted to change the title.  The developer sent code to hid it but I decided to modify it to show something different depending on if you are logged in or not.  The code is:

function tml_widget_title( $title, $instance, $id_base ) {
if ( is_user_logged_in() ){
$title = ‘You are logged in.’;
}
else {
$title = ‘Please login’;
}
return $title;
}
add_filter( ‘widget_title’, ‘tml_widget_title’, 10, 3 );

 

So, once all the code was added, the login experience was much improved.