{"id":1084,"date":"2025-11-01T13:27:39","date_gmt":"2025-11-01T13:27:39","guid":{"rendered":"https:\/\/ykim.synology.me\/wordpress\/?p=1084"},"modified":"2025-11-08T21:01:26","modified_gmt":"2025-11-08T21:01:26","slug":"how-to-redirect-users-to-a-custom-page-after-wordpress-login","status":"publish","type":"post","link":"https:\/\/ykim.synology.me\/wordpress\/how-to-redirect-users-to-a-custom-page-after-wordpress-login-1084\/","title":{"rendered":"How to redirect Users to a Custom Page After WordPress Login"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Redirecting users to a custom page after WordPress login can be achieved using a <strong>plugin<\/strong> (easiest) or <strong>custom PHP code<\/strong> (more control). This is most often done to provide a tailored experience based on the user&#8217;s role.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udee0\ufe0f Method 1: Using a Plugin (Recommended)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Plugins simplify the process, especially if you need different redirects for different user roles (e.g., Subscribers to a member dashboard, Editors to the Posts list).<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Install a Redirection Plugin:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Go to <strong>Plugins<\/strong> \ud83e\udc06 <strong>Add New<\/strong> in your WordPress dashboard.<\/li>\n\n\n\n<li>Search for a plugin like <strong>LoginWP (formerly Peter&#8217;s Login Redirect)<\/strong> or <strong>ProfilePress<\/strong>.<\/li>\n\n\n\n<li><strong>Install and Activate<\/strong> the plugin.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Configure Redirection Rules:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Navigate to the plugin&#8217;s settings page (often found under <strong>Settings<\/strong>, <strong>Tools<\/strong>, or its own menu item like <strong>LoginWP<\/strong>).<\/li>\n\n\n\n<li>Look for the option to <strong>add a new redirect rule<\/strong>.<\/li>\n\n\n\n<li><strong>Set the Condition:<\/strong> Choose the criteria for the redirect:\n<ul class=\"wp-block-list\">\n<li><strong>User Role:<\/strong> (e.g., Subscriber, Editor, Author)<\/li>\n\n\n\n<li><strong>Individual User:<\/strong> (e.g., a specific username)<\/li>\n\n\n\n<li><strong>All Other Users<\/strong> (as a general fallback rule)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Set the Destination:<\/strong> Enter the <strong>URL<\/strong> or select the <strong>Page<\/strong> where the user should be redirected after a successful login. This could be a static page like <code>\/welcome\/<\/code> or a dynamic area like the Author&#8217;s post-editing screen.<\/li>\n\n\n\n<li><strong>Save the Rule:<\/strong> Ensure you save your changes to activate the redirect.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udcbb Method 2: Using Custom Code<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This method involves adding a function to your theme&#8217;s <strong><code>functions.php<\/code><\/strong> file (or a custom plugin) using the WordPress <code>login_redirect<\/code> filter. <strong>Always use a Child Theme<\/strong> when adding custom code.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Access the <code>functions.php<\/code> File:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Go to <strong>Appearance<\/strong> \ud83e\udc06 <strong>Theme File Editor<\/strong> in your dashboard and select your <strong>Child Theme<\/strong> (if you have one). If you don&#8217;t have a child theme, install one or use a code snippet plugin to avoid losing changes upon theme updates.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Insert the Code:<\/strong><ul><li>Add the following PHP snippet. This example demonstrates redirecting an <strong>Administrator<\/strong> to the default dashboard and a <strong>Subscriber<\/strong> to a custom front-end page.<\/li><\/ul><\/li>\n<\/ol>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n\/**\n * Redirects users to a specific URL after login based on their role.\n *\/\nfunction custom_login_redirect_by_role( $redirect_to, $request, $user ) {\n    \/\/ Check if the user object is valid\n    if ( isset( $user-&gt;roles ) &amp;&amp; is_array( $user-&gt;roles ) ) {\n\n        \/\/ Get the user&#039;s highest role (first in the array)\n        $role = $user-&gt;roles&#x5B;0];\n\n        switch ( $role ) {\n            case &#039;administrator&#039;:\n                \/\/ Administrators go to the standard admin area\n                return admin_url();\n            case &#039;subscriber&#039;:\n                \/\/ Subscribers go to a custom front-end page\n                return home_url( &#039;\/member-dashboard\/&#039; );\n            default:\n                \/\/ Fallback for all other roles\n                return home_url();\n        }\n    }\n    \/\/ If the user object is not valid, return the original redirect URL\n    return $redirect_to;\n}\nadd_filter( &#039;login_redirect&#039;, &#039;custom_login_redirect_by_role&#039;, 10, 3 );\n<\/pre><\/div>\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Customize the URLs:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Replace <code>home_url( '\/member-dashboard\/' )<\/code> with the path to your desired custom page.<\/li>\n\n\n\n<li>You can modify the <code>case<\/code> statements to target any user role (e.g., <code>'editor'<\/code>, <code>'author'<\/code>) and set their specific destination.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Save the File:<\/strong> Save the changes and test the login with different user accounts.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udcda Reference List<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>LoginWP (Formerly Peter&#8217;s Login Redirect):<\/strong> A widely used plugin for setting up user, role, and capability-based login redirects in WordPress.<\/li>\n\n\n\n<li><strong>WordPress Code Reference: <code>login_redirect<\/code> Hook:<\/strong> Official documentation on the filter hook used to customize the redirect URL after a user logs in.<\/li>\n\n\n\n<li><strong>Kinsta. (2025). How To Redirect WordPress Users After Login:<\/strong> Article providing detailed instructions for both plugin and code-based methods for managing post-login redirects.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<div style='text-align:center' class='yasr-auto-insert-overall'><\/div><div style='text-align:center' class='yasr-auto-insert-visitor'><\/div>","protected":false},"excerpt":{"rendered":"<p>Redirecting users to a custom page after WordPress login can be achieved using a plugin (easiest) or custom PHP code (more control). This is most often done to provide a tailored experience based on the user&#8217;s role. \ud83d\udee0\ufe0f Method 1: Using a Plugin (Recommended) Plugins simplify the process, especially if you need different redirects for&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","fifu_image_url":"","fifu_image_alt":"","iawp_total_views":0,"footnotes":""},"categories":[87],"tags":[59],"class_list":["post-1084","post","type-post","status-publish","format-standard","hentry","category-wordpress-slug","tag-wordpress"],"yasr_visitor_votes":{"stars_attributes":{"read_only":false,"span_bottom":false},"number_of_votes":0,"sum_votes":0},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/1084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/comments?post=1084"}],"version-history":[{"count":13,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/1084\/revisions"}],"predecessor-version":[{"id":1154,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/1084\/revisions\/1154"}],"wp:attachment":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/media?parent=1084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/categories?post=1084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/tags?post=1084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}