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. Is there a plugin or resource for custom implementation for OAUTH and regular user login?
  4. Login cookies set as wrong domain
  5. edit_user_profile and show_user_profile are not firing inside a class
  6. How to use login_redirect with a user capability
  7. Login Customizer doesn’t change the background of the register form
  8. easy steps to make front end form without plugin
  9. How to create multiple users at once?
  10. Shortcode to update user meta
  11. Change wp-login to custom URL login page
  12. Multisite – maximum number of users with specific role
  13. How do I get the user ID of the user that was updated in WordPress?
  14. Understanding State in WordPress Multisites
  15. How to have sample page for each new register users in a membership website
  16. How to get all posts belongs to a user between a certain date
  17. Login problem after installing my written plugin [closed]
  18. Specific way to allow WordPress users to view their current password? And edit it?
  19. Too many login attempts
  20. how can I query all wordpress users of a blog
  21. Get ‘Headers already sent’ error for the plugin I am creating when I try to login
  22. Add Content to Content()
  23. Custom Login Page — wp_signon Headers Already Sent?
  24. Is there a plugin for WordPress for creating ‘Accounts’ where all users who belong to that Account can only see Account data? [closed]
  25. Add User Role: Pre-saved in User-Meta [SOLVED]
  26. get_users(); Is an Undefined Function When Used in Cron Job
  27. Theme My Login Shortcode Doesn’t Return Anything
  28. Possibility to login without password
  29. how do i change my website facebook login button to another text immediately user login? [closed]
  30. How limit user connection?
  31. WordPress unable to write files in the server
  32. Custom Login page with custom redirects for each user?
  33. how to make dynamic subdomain for each user registering?
  34. How to pass a query string to another page on the same site?
  35. WordPress /users/me endpoint request forbidden
  36. Mutliple users editing single document in wordspress
  37. Custom PHP Page Using WordPress login
  38. Remove specific administrator’s capability
  39. How to Use the Filter “sidebar_login_widget_form_args”
  40. Plugin permissions for Editor role
  41. Personalized Author Area
  42. Manage PDF downloads and protected pages
  43. How to auto strip hyperlinks & images in wordpress post
  44. If I use an alternative login (e.g. CAS or other SSO) plugin, is my site protected from the recent brute force login attempts?
  45. Completely remove ability to create users?
  46. Role based permission edit for plugins
  47. login in wordpress using gmail account
  48. Creating teams of users in WordPress
  49. WordPress plugin for Limited days user
  50. Plugin privelages for “editors”
  51. How can I replace content on site generated from plugin without changing plugin
  52. Shortcode not displaying HTML within the function
  53. Can’t save changes or modify settings in Dashboard but Pages and Posts are fine
  54. Disable Author Archive just for certain roles in bulk
  55. Linking form to user meta fields
  56. Auto populate a user custom field from another user custom field
  57. WordPress Multisite Profile Picture Sync Error with Nextend Social Login Plugin
  58. Plugin or ways to limit number of users logging in the website,
  59. force logged in user to stay in the dashboard
  60. Can we hide a certain user in WP?
  61. Share login credential with QR code
  62. How to implement data residency in my WordPress site
  63. Which membership plugin for a simple sign in? Personal areas for customers
  64. how to create user profile pages and display them based on users roles
  65. Discern a specific plugin’s action hooks
  66. Clean old users
  67. After reading 3 story by user ask for subscription popup
  68. User updating their profile wipes my custom fields
  69. Login/password protected “client page”
  70. WordPress Admin login redirect to homepage
  71. Comment restrictions Wodpress
  72. How To Export User’s Custom Fields in CSV or XLSX
  73. Get all user meta_keys and then group users by matching values
  74. https rewrite not working for All in one security Brute force > rename login url
  75. Searchable Semi Random Number Generator on User Profiles
  76. How do I run my custom function in my plugin when a wordpress user is deleted?
  77. How can I show login popup when user clicks on download button
  78. When the user entered an unauthorized url redirect to login page
  79. How to show private pages based on a user’s role?
  80. How can I store user preferences in WordPress and retreive them later?
  81. Simulate Update User button click
  82. Update User Meta Via Ajax
  83. User Following System
  84. Why does WordPress use cookies for /wp-admin and /wp-content/plugins for non-admin users [duplicate]
  85. User / membership Plugin [closed]
  86. How to see in Edit Comments if comment is from User and her Roles
  87. Custom User Notice Upon Login
  88. using wordpress login details for other website / application / forum?
  89. How can I save cookies to members
  90. wp_signon returns user, in popup window, but the user is not logged in
  91. How to Create Custom Dashboard for my Laundry Website?
  92. Paid Memberships Pro, Display User Limit
  93. wp_login_form() ignoring login_form action hook
  94. Confusing problem with displaying message recipient metadata
  95. Every time I use wp_get_current_user() my plugin breaks
  96. How to order users alphabetically by name? in plugin UPME
  97. User content database [closed]
  98. Users Ultra: Hide asterisk for required registration fields?
  99. Defined user role to access plugin’s pages
  100. Auto-login from backend
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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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