[英]'Login' value for non logged user and 'Log Out' value for logged in user
I have a 'Login' call to action javascript button. 我有一个“登录”号召性用语javascript按钮。 My button is working with javascript for to action login and registration.
我的按钮正在使用javascript进行登录和注册。 The button code has a value called Login.
该按钮代码的值称为Login。 So the button is always displaying the Login text as a button name all time.
因此,按钮始终始终将登录文本显示为按钮名称。
I want- 我想要-
Can you please fix by editing my code? 您能编辑我的代码来解决吗?
See my code: 看我的代码:
<input type="button" style="background-color: red" value="Login" data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onclick="tmpl_login_frm();"><aside id="sidebar-contact_page_sidebar" class="sidebar large-3 small-12 columns">
if you use this small piece of php code around your login button, it will use different code/show a different button when the user is logged in or is not logged in. 如果您在登录按钮周围使用这小段php代码,则在用户登录或未登录时,它将使用不同的代码/显示不同的按钮。
Please note the changed values and the echoed strings above button echo 请注意更改的值和按钮echo上方的echoed字符串
see wordpress codex reference link for more information https://codex.wordpress.org/Function_Reference/is_user_logged_in 有关更多信息, 请参见wordpress Codex参考链接。https://codex.wordpress.org/Function_Reference/is_user_logged_in
<?php
if ( is_user_logged_in() ) {
echo 'user is logged in, show logout button';
echo '<input type="button" style="background-color: red" value="Logout" data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onclick="tmpl_login_frm();"><aside id="sidebar-contact_page_sidebar" class="sidebar large-3 small-12 columns">';
} else {
echo 'user is not logged in, show login button';
echo '<input type="button" style="background-color: red" value="Login" data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onclick="tmpl_login_frm();"><aside id="sidebar-contact_page_sidebar" class="sidebar large-3 small-12 columns">';
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.