Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Change Login or Logout text based on status

You have the PHP IF statement needed, is_user_logged_in().

Just add your button to that and you should be good. Something this…

<?php if (is_user_logged_in()) {
    echo '<button type="button" class="show-btn">LOG IN</button>';
} else {
    echo '<button type="button" class="show-btn">REGISTER</button>';
}; ?>

Note: You have an extra </div> in your code above.

Related Posts:

  1. How to: PHP Log Out Link?
  2. Login/logout in header
  3. Check if user had autologin & if so, logout
  4. Log out without confirmation request (nonce)
  5. User registration followed by automatic login
  6. Adding “Remember Me” in custom login
  7. How to change the wp-login.php page title?
  8. How build a custom login/register form with error handling?
  9. How to log out everywhere else, destroy all sessions “all other devices”?
  10. Changing user_nicename
  11. WordPress 4 invalid username special charachters issue
  12. How to place login logout link on menu that redirects users back to current page?
  13. How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
  14. How to resolve error “Cookies are blocked due to unexpected output.”?
  15. Trying to use Ternary operators with WP Conditionals
  16. Using a nonce in a Custom Login Form
  17. Constructing a custom login form using ajax
  18. automated tests as a user?
  19. How to do conditional publishing?
  20. Remove username in emails or swap username for email
  21. woocommerce and is_user_logged_in() if not redirect to homepage
  22. Check if user is logged in when clicking certain links on certain pages
  23. conditional statement for custom taxonomy
  24. Creating login session via CURL
  25. Admin username and password
  26. Add user settings to specific roles
  27. How to display conditional-content if wp_nav_menu( $args ) retruns something
  28. Create a new usermeta field for users
  29. Is it necessary to sanitize wp_set_password user input?
  30. How to give new users two specific user role options upon WordPress user registration
  31. How to Arrange PHP Files to Allow for Multiple Types of Pages?
  32. Wp-login appears White Screen, Error: Cannot modify header information
  33. Reordering Buddy Press profile navigation [closed]
  34. Programmatic Login from 3rd Party site
  35. Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
  36. How to debug my custom login form looping intermittently
  37. getting logged in user info (wp-load.php) from parent directory
  38. Login to wordpress by clicking a link and specifying usernaname and password in url
  39. Is_front_page inside header.php is always returning true
  40. Log in / Log Out Custom Button
  41. Should `wp_login` be used since it’s deprecated?
  42. Advanced Custom Fields – display label and value only if value entered
  43. Change CSS based on is_user_logged_in
  44. How can I open up my administrative panel to everyone?
  45. How to check if the current page is at a specified path in the URL?
  46. Add class to DIV depending on page loaded
  47. Force Users To Relogin
  48. How to hook a logout funtion for specific usr role in wordpress?
  49. How can I add a new row in a separate database when someone registers via WordPress?
  50. Can I set up a hover animation in CSS depending on a PHP conditional?
  51. Lost in trying to create user database system
  52. Logout redirects to default page
  53. Shortcode to log user into current URL
  54. Multidimensional Array
  55. Conditional featured image with youtube thumbnail
  56. PHP getting error when trying to access WP-Admin Dashboard
  57. I installed WordPress locally now how do I login?
  58. If user is logged in not working
  59. Change homepage content if user is logged in – BuddyPress
  60. How to make a conditional statement within $output in shortcodes.php?
  61. Conditionally remove comments and post meta in functions.php
  62. exclude custom post type from running a function
  63. include content within conditional statement?
  64. is_user_logged_in returning nothing on custom page
  65. Show label for value only when value exists, basic php
  66. Help with accessing wp-admin page and resolving error messages
  67. Admin Panel 404 Error after login
  68. PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
  69. How to block specific user id in custom login form?
  70. Change button link to add nonce
  71. Conditional formatting on data fetched from MYSQL
  72. Having trouble creating two shortcodes, one for logged in user and one for visitors
  73. Find and print first entry from WordPress post in custom excerpt?
  74. Restrict wordpress access to logged users only
  75. Infinite loop when logging out using custom login form
  76. Adding if statement
  77. Display specific page if user signed in
  78. Refresh page after login with litespeed cache
  79. Redirect after login depending on the URL
  80. Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
  81. Redirecting the lost password page request when using a custon login page
  82. is_user_logged_in() not working in homepage
  83. Check if a user is logged into my WordPress site which is on a different server
  84. Newbie question. Login/Registration. New PHP page
  85. List users in a dropdown for login
  86. If else statement based on referral URL
  87. Not logged in when using http
  88. add bootstrap modal after login in wordpress
  89. If Month=Particular month display content [closed]
  90. White screen after login attempt
  91. Php conditional help needed
  92. Redirect users not logged in to the standard login page (and back) from some posts and pages
  93. How to replace wp-admin login page to another location?
  94. Not able to see the error [closed]
  95. Check user last login date
  96. Prevent users from display default wordpress login form
  97. login redirect based on user role not work as expected
  98. How to change wp-admin and wp-login urls
  99. wp_login_url always redirects me to wp-admin
  100. change div text and link for logged in users
Categories PHP Tags conditional-content, login, logout, php
How do I delete a wordpress user from giant database?
Add Product Permalink in woocommerce admin order page

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Disable image compression for WebP
  • At what stage does wp_ajax hooks gets applied during WordPress request?
  • How to create specific wordpress Table
  • How to get variable from other function inside class function using add_action for Ajax call
  • Some images not loading after changing IP on local wordpress install
  • search posts by POST ID
  • Elementor Contact Form Submit button has empty class
  • Duplicate Slugs on multilingual site (with Polylang)
  • Timeline from diferent wordpress api urls endpoint works, but diferent date
  • $attributes not defined in block.json PHP template for ACF blocks
© 2023 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress