Changing the visibility of button value for logged in Wp user

I am using a ‘Login’ call to action javascript button. The button code has a value called Login. So the button is always displaying the Login text as a button name all time.

But I want, when any user logged in the site then this button name will be changed and all users will see the button name as Log Out. If someone click on the Log Out button then he will logged out.

Read More

I want-

  • Logged out users/visitors will see the button name ‘Login’
  • Logged in users will see the button name ‘Log Out’ with log out action.

Can you please fix by editing my code?

See my current code below:

 <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">

Thanks.

Related posts

2 comments

  1. you can try

    <a href="<?php if(is_user_logged_in()): ?>logged.php<?php else:?>not_loggded.php<?php endif; ?>">
    <?php if(is_user_logged_in()): ?> 
    <?php _e('Logged); ?>
    <?php else: ?>
    <?php _e('Not logged); ?>
    <?php endif; ?>
    </a>
    
  2. Try this

     <input type="button" style="background-color: red" value="<?php if(is_user_logged_in()) { echo 'Logout'; } else { echo '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">
    

Comments are closed.