johnzoro on "How do I easily add a register and login/logout link"

ساخت وبلاگ

as the title says

The easiest way to add that would be to add the Meta widget at Appearance -> Widgets in your site's Dashboard to any widget area.

The next easiest would be simply add a link to http://www.johnzoro.com/wp-login.php wherever you want.

ah! it's actually for my pub shed website.

what about a register link?

is there a register.php page?

You'll have to enable registration first at Settings -> General in your Dashboard.

The registration link will appear on the login form.

but if you're logged in already, adding that html link, it still shows

what i want is if you're not logged in, it has 2 links one that says login and one that says register

then when you are logged in or have registered it just shows a log out link and also your name

like "Welcome Barry (Logout) " or whatever

Right, the Meta widget will do that for you.

I had a read of https://codex.wordpress.org/Function_Reference/wp_register but i'm still a bit confused.

If i want a simple link that just says register would I just use

<?php wp_register(); ?>

because it doesn't seem to work for me?

doesn't seem to work

anything showing at all?
behaviour different than expected?

some code that works:

<?php echo ' <span class="register">'; wp_register('',''); echo '</span> '; echo ' <span class="loginout">'; if( is_user_logged_in() ) { $current_user=wp_get_current_user(); echo 'Welcome ' . $current_user->user_login . ' ('; wp_loginout(''); echo ')'; } else { wp_loginout(''); } echo '</span> ';
?>

the added html is to make formatting easier.

ok this seems to work

add_action( 'generate_before_header','rlmenu' );
function rlmenu()
{ echo ' <span class="login_menu">'; wp_register('',''); if( is_user_logged_in() ) { $current_user=wp_get_current_user(); echo 'Welcome ' . $current_user->user_login . ' ('; wp_loginout(''); echo ')'; } else { wp_loginout(''); } echo '</span> ';
}

but it's only making the text have the background i want

am i missing something

i want the class login_menu to go along the entire width of the menu above the header

pubshed.co.uk is my website

add_action( 'generate_before_header','rlmenu' );
function rlmenu()
{ echo ' <div class="login_menu">'; wp_register('',''); if( is_user_logged_in() ) { $current_user=wp_get_current_user(); echo 'Welcome ' . $current_user->user_login . ' ('; wp_loginout(''); echo ')'; } else { wp_loginout(''); } echo '</div> ';
}

OK I got it how I want it but the register and the login links are too close together.

How can i add a space between them or a / to separate them?

johnzoro
Member
Posted 15 minutes ago #

i fixed the space issue by adding a nbsp;

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 169 تاريخ : دوشنبه 30 فروردين 1395 ساعت: 16:02