M
M
MisTFoR2020-12-16 19:13:22
WooCommerce
MisTFoR, 2020-12-16 19:13:22

How to display the "logout" button after authorization?

Hello.
I have two links, with login and registration. How to display the "Exit" button after authorization in the account?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Litvinenko, 2020-12-16
@MisTFoR

I took it from the project, I think it will help

<ul class="header-top-register">
  <?php if(is_user_logged_in()): 
    $account_page = get_page_by_path('my-account', '', 'page');
  ?>
    <li><a href="<?php the_permalink($account_page) ?>"><?php _e('Кабінет', 'viche') ?></a></li>
    <li><a href="<?php echo wp_logout_url(get_permalink()); ?>"><?php _e('Вихід', 'viche') ?></a></li>
  <?php else: ?>
    <li><a href="javascript:void(0);" class="open-modal-btn" data-target="modal-sign-in"><?php _e('Авторизація', 'viche') ?></a></li>
    <li><a href="javascript:void(0);" class="open-modal-btn" data-target="modal-register"><?php _e('Реєстрація', 'viche') ?></a></li>
  <?php endif; ?>
</ul>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question