• Hi there,

    is there any possibility to use just a shortcode instead of using the menu-function to add the login/logout functionality? Thanks in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter digitalcreed

    (@digitalcreed)

    I’ve done a quick’n’dirty solution for this, by adding the code into my functions.php

    <?php
    
    add_shortcode( 'login_logout_label', function($args) {
    if(!is_user_logged_in()) {
    return 'Login';
    } else {
    return 'Logout';
    }
    });
    
    add_shortcode( 'login_logout_href', function($args) {
    $login_page_url = get_option('lolmi_login_page_url', wp_login_url());
    $logout_redirect_url = get_option('lolmi_logout_redirect_url', home_url());
    return (is_user_logged_in()) ? wp_logout_url($logout_redirect_url) : $login_page_url;
    });
    
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Shortcode’ is closed to new replies.