Quantcast
Channel: User Michael - WordPress Development Stack Exchange
Viewing all articles
Browse latest Browse all 44

Answer by Michael for Adding register & login in Wordpress website

$
0
0

integrating some of the suggested functions into your code:

<?php        $c_user = wp_get_current_user();        if( !is_user_logged_in( $c_user->ID ) ) :        echo '<a href="' . esc_url( wp_login_url() ) . '" alt="' . esc_attr( 'Login', 'textdomain' ) . '">';        echo _e( 'Login', 'textdomain' );        echo '</a>';        wp_register(' / ', '');        else :            echo 'Hello ' . $c_user->display_name . ', ';            echo '<a href="' . esc_url( wp_logout_url( home_url() ) ) . '" alt="' . esc_attr( 'Logout', 'textdomain' ) . '">';        echo _e( 'Logout', 'textdomain' );        echo '</a>';        endif;?>

some remarks:

  • for the 'Register' link to show, you need to have ticked in the dashboard:'Settings' - 'General' - 'Membership [ ] Anyone can register

  • the 'Logout' will redirect to the home page; if you don't want that, remove home_url() from the code


Viewing all articles
Browse latest Browse all 44

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>