“My Account” (woocommerce) main menu item to show “display_name” for logged in user

This is particular to the Avada theme combined with woocommerce, but hoping someone here has a solution.

In the Avada theme’s options, you can opt to include a “My Account” menu item in the main menu. This places a menu item with the text “My Account” with sub-menus beneath it. What I want to do is have this say “My Account” until the user logs in, and then have it say “Welcome, display_name”.

I see this in avada functions, which is all I can find that looks related to this function:

$my_account_link_contents = ( ‘Right’ == Avada()->settings->get( ‘header_position’ ) ) ? $caret_icon . esc_html__( ‘My Account’, ‘Avada’ ) : esc_html__( ‘My Account’, ‘Avada’ );

I’ve tried several versions of an IF function in my child theme, using is_user_logged_in() and wp_get_current_user() but it’s proving to be beyond my php skills. Any help would be much appreciated.

Aside from Avada’s particular code, is there a way to identify a menu item by its li text and filter it using an IF statement?

Read more here:: “My Account” (woocommerce) main menu item to show “display_name” for logged in user

Leave a Reply

Your email address will not be published. Required fields are marked *