user registration - Adding register & login at top right corner

admin2025-01-07  4

I am using the HitMag WordPress theme. On the website, register & login is showing on the sidebar (widgets). But I want to show register & login at the top right corner in button form. I want to display like this .png

Here is my header.php code:-

Could anyone let me know how to display buttons?

I am using the HitMag WordPress theme. On the website, register & login is showing on the sidebar (widgets). But I want to show register & login at the top right corner in button form. I want to display like this https://i.sstatic.net/pbJpW.png

Here is my header.php code:- https://pastebin.com/n4tund6Z

Could anyone let me know how to display buttons?

Share Improve this question asked Apr 2, 2020 at 19:53 imtango30imtango30 93 bronze badges 1
  • Please post your code. This is not a custom coding service. – Brad Dalton Commented Apr 6, 2021 at 16:20
Add a comment  | 

1 Answer 1

Reset to default 0

UPDATED: In the header.php you have these lines:

     </div><!-- .hm-site-title -->
</div><!-- .site-branding-content -->

You'll want to put your div tag for the register and login buttons between them:

</div><!-- .hm-site-title -->
    <div class="hm-custom-login-btns">
        <?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_e( 'Login', 'textdomain' ) . '">';
            echo _e( 'Login', 'textdomain' );
        echo '</a>';
        wp_register('', '');
        else :
            echo 'Hello ' . $c_user->display_name;
        endif;
        ?>
    </div>
</div><!-- .site-branding-content -->

Then you'll need to work with CSS to get it all positioned correctly. You'll probably need to adjust the container widths, and either float elements left and right or use display:flex and associated properties to lay it all out.

The Login & Register link generating PHP can be found here: https://developer.wordpress.org/reference/functions/wp_login_url/

https://developer.wordpress.org/reference/functions/wp_register/

And here's how you obtain the user's display name and other info: https://developer.wordpress.org/reference/functions/wp_get_current_user/

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736259628a603.html

最新回复(0)