• Resolved wall01

    (@torch01)


    Hello guys. I would like to: When the user logs into his account, the “Enter” button changes to “Exit”, and vice versa how would I do it?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi. Please use login logout register plugin for this facility.

    Plugin Contributor James Koster

    (@jameskoster)

    Hey,

    If you’re not keen on using a plugin, try the following function;

    function display_login_out_link() {
    	if ( is_user_logged_in() ) {
    		$url   = esc_url( wc_logout_url( wc_get_page_permalink( 'myaccount' ) ) );;
    		$label = esc_html__( 'Exit' );
    	} else {
    		$url   = esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) );;
    		$label = esc_html__( 'Enter' );
    	}
    
    	echo '<a href="' . $url . '">' . $label . '</a>';
    }

    Just call that in a template like so; <?php display_login_out_link(); ?>.

    James
    Designer @ Automattic

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to change button name when user signs in’ is closed to new replies.