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. Change the footer text on the login page
  11. Changing user_nicename
  12. Conditional Statement – check if post has an attachment image
  13. WordPress 4 invalid username special charachters issue
  14. How to place login logout link on menu that redirects users back to current page?
  15. How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
  16. How to resolve error “Cookies are blocked due to unexpected output.”?
  17. Trying to use Ternary operators with WP Conditionals
  18. Using a nonce in a Custom Login Form
  19. Constructing a custom login form using ajax
  20. automated tests as a user?
  21. How to do conditional publishing?
  22. Remove username in emails or swap username for email
  23. woocommerce and is_user_logged_in() if not redirect to homepage
  24. Check if user is logged in when clicking certain links on certain pages
  25. conditional statement for custom taxonomy
  26. PHP If user is logged in & on home page redirect
  27. WordPress shows registration link for non logged users
  28. Creating login session via CURL
  29. Admin username and password
  30. Add user settings to specific roles
  31. How to display conditional-content if wp_nav_menu( $args ) retruns something
  32. Recovering WP Login Credintials in Code?
  33. Create a new usermeta field for users
  34. Is it necessary to sanitize wp_set_password user input?
  35. WordPress custom login form using Ajax
  36. Redirect to a different page through registration, depending on page
  37. How to give new users two specific user role options upon WordPress user registration
  38. How to Arrange PHP Files to Allow for Multiple Types of Pages?
  39. What is the correct way to write this conditional statement?
  40. Wp-login appears White Screen, Error: Cannot modify header information
  41. Reordering Buddy Press profile navigation [closed]
  42. Why is my cookie not unsetting upon logout? [closed]
  43. User management system similar to wordpress one?
  44. Programmatic Login from 3rd Party site
  45. Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
  46. How to debug my custom login form looping intermittently
  47. getting logged in user info (wp-load.php) from parent directory
  48. Problem with login form
  49. Login to wordpress by clicking a link and specifying usernaname and password in url
  50. Is_front_page inside header.php is always returning true
  51. Log in / Log Out Custom Button
  52. Should `wp_login` be used since it’s deprecated?
  53. How to redirect users based on role and content of redirect_to?
  54. Advanced Custom Fields – display label and value only if value entered
  55. Change CSS based on is_user_logged_in
  56. PHP conditional script issue
  57. How to display login form anywhere, when user isn’t logged in, without redirecting?
  58. How can I open up my administrative panel to everyone?
  59. How to check if the current page is at a specified path in the URL?
  60. Add class to DIV depending on page loaded
  61. Force Users To Relogin
  62. How to hook a logout funtion for specific usr role in wordpress?
  63. How can I add a new row in a separate database when someone registers via WordPress?
  64. Can I set up a hover animation in CSS depending on a PHP conditional?
  65. One account with multiple logins
  66. Lost in trying to create user database system
  67. Logout redirects to default page
  68. Shortcode to log user into current URL
  69. Multidimensional Array
  70. Conditional featured image with youtube thumbnail
  71. PHP getting error when trying to access WP-Admin Dashboard
  72. I installed WordPress locally now how do I login?
  73. If user is logged in not working
  74. Change homepage content if user is logged in – BuddyPress
  75. How to make a conditional statement within $output in shortcodes.php?
  76. Show login greeting above sub-menu links?
  77. Conditionally remove comments and post meta in functions.php
  78. exclude custom post type from running a function
  79. include content within conditional statement?
  80. is_user_logged_in returning nothing on custom page
  81. Show label for value only when value exists, basic php
  82. Help with accessing wp-admin page and resolving error messages
  83. Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
  84. Can’t log in to WordPress wp-admin after adding code to functions.php
  85. Admin Panel 404 Error after login
  86. PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
  87. How to block specific user id in custom login form?
  88. Change button link to add nonce
  89. Conditional formatting on data fetched from MYSQL
  90. Having trouble creating two shortcodes, one for logged in user and one for visitors
  91. Call WP Rest-Api to GET /users/me returned NOTHING in console
  92. Find and print first entry from WordPress post in custom excerpt?
  93. Restrict wordpress access to logged users only
  94. Infinite loop when logging out using custom login form
  95. Menu not updating for logged in users after redirect
  96. Adding if statement
  97. how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
  98. Issues adding Recaptcha v3 to WordPress Registration
  99. Display specific page if user signed in
  100. Refresh page after login with litespeed cache
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

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 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