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

On button click, redirect users to registration page instead of another page

You’ll need to find out what theme template file is being used to display the /portfolio/ page – page.php, page-portfolio.php, tpl-portfolio.php, or something along those lines.

Then, if you don’t already have a child theme, create one.

Then, copy the template file into your child theme, and at the very top – before anything else – add:

// If the user is not logged in
if( !is_user_logged_in() ) {
    // send them to the login screen
    // once they log in, they will automatically return to this page
    auth_redirect();
} else {
    // move all your other code into this condition
}

As the comments note, if the user isn’t logged in, they’ll be redirected to the login page. Once they are logged in, they’ll be redirected back to the portfolio page.

Related Posts:

  1. How to create custom LOGIN and REGISTRATION forms?
  2. Janrain/Simple Modal under Redirected Domain
  3. WP_User_Query and non-unique usermeta data
  4. Loading posts associated only to the logged in user on recent posts page
  5. Change success message in plugin Theme my login
  6. How can i force Display names to be the same as Usernames?
  7. How to get Login Error messages on a custom template
  8. How can a Firebase user registration and login be integrated into a WordPress site?
  9. How to get user-meta from Social Login registered users?
  10. Auto login using Active Directory and Windows Authentication
  11. How can I make content disappear when a user logs in?
  12. Tracking last login and last visit
  13. login to wordpress with Get variables instead of Post
  14. $current_user var returns NULL
  15. Multisite functions to communicate with individual site functions
  16. WordPress Plugin for One-Time Event Registration? [closed]
  17. Will WordPress username displayed somewhere in the site?
  18. wordpress custom login successful redirect hook
  19. WordPress with CAS+LDAP and standard WP accounts
  20. Upload files programmatically to users
  21. How to show popup to a group of users?
  22. Current user in plugin returns NULL
  23. wp_authenticate but not logged in
  24. update_user_meta add value on the top on existing value
  25. Force [wordpress_social_login] shortcode to display where it is embedded [closed]
  26. Cannot login to ADMIN even after changing password in phpmyadmin
  27. How to upload user profile image from frontend in wordpress ?
  28. Average Account Age
  29. How do i login when i cant access wp-login.php?
  30. How to keep users unique id stored in session in addition to IP in WordPress plugin?
  31. Why is my staging subdomain not sending wordpress_logged_in cookies?
  32. New User Form – Custom Menu Page
  33. How can I force users to a particular subdomain to log in for MU (Multisite)?
  34. How to save generated JWT token to cookies on login?
  35. Contributive page where people logged in can write
  36. How to create restrict content to users (by user, not by role)
  37. Custom User meta field display
  38. Login cookies set as wrong domain
  39. edit_user_profile and show_user_profile are not firing inside a class
  40. Login Customizer doesn’t change the background of the register form
  41. Multisite – maximum number of users with specific role
  42. How to get all posts belongs to a user between a certain date
  43. Login problem after installing my written plugin [closed]
  44. Specific way to allow WordPress users to view their current password? And edit it?
  45. Possibility to login without password
  46. how do i change my website facebook login button to another text immediately user login? [closed]
  47. WordPress unable to write files in the server
  48. how to make dynamic subdomain for each user registering?
  49. Custom PHP Page Using WordPress login
  50. Remove specific administrator’s capability
  51. How to Use the Filter “sidebar_login_widget_form_args”
  52. Personalized Author Area
  53. If I use an alternative login (e.g. CAS or other SSO) plugin, is my site protected from the recent brute force login attempts?
  54. Completely remove ability to create users?
  55. Creating teams of users in WordPress
  56. WordPress plugin for Limited days user
  57. How can I replace content on site generated from plugin without changing plugin
  58. Can’t save changes or modify settings in Dashboard but Pages and Posts are fine
  59. Linking form to user meta fields
  60. WordPress Multisite Profile Picture Sync Error with Nextend Social Login Plugin
  61. force logged in user to stay in the dashboard
  62. Share login credential with QR code
  63. How to implement data residency in my WordPress site
  64. Discern a specific plugin’s action hooks
  65. Clean old users
  66. User updating their profile wipes my custom fields
  67. WordPress Admin login redirect to homepage
  68. Comment restrictions Wodpress
  69. https rewrite not working for All in one security Brute force > rename login url
  70. When the user entered an unauthorized url redirect to login page
  71. Simulate Update User button click
  72. Update User Meta Via Ajax
  73. User Following System
  74. User / membership Plugin [closed]
  75. How to see in Edit Comments if comment is from User and her Roles
  76. using wordpress login details for other website / application / forum?
  77. How can I save cookies to members
  78. wp_signon returns user, in popup window, but the user is not logged in
  79. How to Create Custom Dashboard for my Laundry Website?
  80. Every time I use wp_get_current_user() my plugin breaks
  81. User content database [closed]
  82. Users Ultra: Hide asterisk for required registration fields?
  83. Defined user role to access plugin’s pages
  84. AJAX login without a plugin does not work. when add a action to function.php
  85. Plugins effecting layout & login
  86. Redirect default login page to a custom page [duplicate]
  87. First argument is expected to be a valid callback for cp_admin_init and _canonical_charset
  88. How to set different users for different pages?
  89. HTTP Error 403 When Trying to Login
  90. Change All Login/Signup Links in Plugin
  91. Want to add post to user dashboard
  92. How to make wordpress backend mobile optimized.?
  93. How to Find WordPress site has backdoor login Codes
  94. how to embed a crop feature for cropping images uploaded by the user
  95. How to give access to the particular page in wordpress for specific username/email NOT roles [closed]
  96. Share or sync user table data with another user table
  97. WordPress Homepage Login
  98. I cannot login after installing the wp-login timeout setting plugin
  99. Issue: Unable to Access WordPress Admin and Database Errors
  100. Lost Password of my site, how to reset wordpress password?
Categories plugins Tags login, plugins, users
Print only parent categories of post in custom RSS feed
meta_query orderby sort multiple keys

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