How to edit the Login/Register button link

Hi there,

If you press The Login/Register button on this website u will go to eensnelalternatief.com/wp-admin. But I need it to go to https://eensnelalternatief.com/mijn-account/. I cant find a option to edit the button or change the button to an other link. I hope you can help me! I did what was suggested on this page https://forums.athemes.com/t/about-the-login-register-button-linking/24228 But that didnt work. In the Javascript i tried some things my self because the stock script did not work.

Kind Regards,

Kevin Vonk


Hello there,

The code shouldn’t have to be placed in the same place, in your screenshot, that’s room for jQuery code. The below code is actually a piece PHP function and shouldn’t be edited.

    /**
     * Get WC page URL
     */
    add_action( 'wp_enqueue_scripts', 'leto_child_wc_pages', 9999 );
    function leto_child_wc_pages() {

      $wc_pages = array(
        'my_account' => get_permalink( wc_get_page_id( 'myaccount' ) ),
      );

      wp_localize_script( 'leto-main', 'wc_pages', $wc_pages );

    }

WordPress will read wc_get_page_id( ‘myaccount’ ) as page ID of your selected account page.

To apply PHP code to your site, add it with functionality plugin like Code Snippets.

Then add this code to Appearance > Custom JavaScript:

    (function($){

      if( $('.nav-link-account a').length ) {
        $('.nav-link-account a').attr('href', wc_pages.my_account);
      }

    })(jQuery);

Since site caching applied in your site, you have to flush/clear it when added a new code. Otherwise, it won’t take immediate effect. https://codex.wordpress.org/I_Make_Changes_and_Nothing_Happens

Regards,
Kharis

1 Like

Hi Kharis,

Thank you for the quick reply! This is what I did and now the button reloads the page but it don`t navigate yet…
What did I do wrong?

Kind Regards,

Kevin Vonk

Hello there,

Check your snippet once again, please. And ensure it’s enabled in the front-end.

Regards,
Kharis

1 Like

Hi Kharis,

There was a problem in the program, so now it works !
Thank you !

Kind Regards,

Kevin Vonk

Great!

You’re welcome! Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis

1 Like