{"id":1147,"date":"2012-03-23T06:47:06","date_gmt":"2012-03-23T06:47:06","guid":{"rendered":"http:\/\/www.vishmax.com\/en\/?p=1147"},"modified":"2012-05-19T10:43:26","modified_gmt":"2012-05-19T10:43:26","slug":"wordpress-redirect-user-after-login","status":"publish","type":"post","link":"http:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/","title":{"rendered":"WordPress Redirect User after Login"},"content":{"rendered":"<p>You can use the bellow code in your WordPress Theme to redirect a user after login according to the role assigned to them.Just open your function.php and copy and paste the code into it. Thats all, it will work fine with almost versions of WordPress. If any issues occured plesae inform us using comment box below.<\/p>\n<pre lang=\"php\">\r\n<?php\r\n\r\nfunction Redirect_User()\r\n{\r\n\t\/\/retrieve current user info \r\n\tglobal $current_user;\r\n     \tget_currentuserinfo();\r\n \t\/\/If login user role is Subscriber\r\n     \telse if ($current_user->user_level == 0)\r\n     \t{\r\n        \twp_redirect( home_url() ); exit;\r\n     \t}\r\n \t\/\/If login user role is Contributor\r\n \telse if ($current_user->user_level > 1)\r\n \t{\r\n        \t wp_redirect( home_url() ); exit;\r\n     \t}\r\n  \t\/\/If login user role is Editor\r\n     \telse if ($current_user->user_level >8)\r\n     \t{\r\n\t\twp_redirect( home_url() ); exit;\r\n     \t}\r\n \t\/\/ For other rolse \r\n\telse\r\n     \t{\r\n      \t\t$redirect_to = 'http:\/\/example.com\/';\r\n        \treturn $redirect_to;\r\n \t}\r\n}\r\nadd_action('admin_init','Redirect_User');\r\n\r\n?>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You can use the bellow code in your WordPress Theme to redirect a user after login according to the role assigned to them.Just open your function.php and copy and paste the code into it. Thats all, it will work fine with almost versions of WordPress. If any issues occured plesae inform us using comment box [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[44],"tags":[72,49,83],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.2.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WordPress Redirect User after Login - Vishmax.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WordPress Redirect User after Login - Vishmax.com\" \/>\n<meta property=\"og:description\" content=\"You can use the bellow code in your WordPress Theme to redirect a user after login according to the role assigned to them.Just open your function.php and copy and paste the code into it. Thats all, it will work fine with almost versions of WordPress. If any issues occured plesae inform us using comment box [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/\" \/>\n<meta property=\"og:site_name\" content=\"Vishmax.com\" \/>\n<meta property=\"article:published_time\" content=\"2012-03-23T06:47:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-05-19T10:43:26+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93\"},\"headline\":\"WordPress Redirect User after Login\",\"datePublished\":\"2012-03-23T06:47:06+00:00\",\"dateModified\":\"2012-05-19T10:43:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/\"},\"wordCount\":63,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/#organization\"},\"keywords\":[\"Code Library\",\"WordPress\",\"WP Snippets\"],\"articleSection\":[\"Labs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/\",\"url\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/\",\"name\":\"WordPress Redirect User after Login - Vishmax.com\",\"isPartOf\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/#website\"},\"datePublished\":\"2012-03-23T06:47:06+00:00\",\"dateModified\":\"2012-05-19T10:43:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vishmax.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WordPress Redirect User after Login\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vishmax.com\/en\/#website\",\"url\":\"https:\/\/www.vishmax.com\/en\/\",\"name\":\"Vishmax.com\",\"description\":\"Websites, Hosting &amp; Full-Stack Solutions in Calicut\",\"publisher\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vishmax.com\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vishmax.com\/en\/#organization\",\"name\":\"Vishmax.com\",\"url\":\"https:\/\/www.vishmax.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png\",\"contentUrl\":\"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png\",\"width\":150,\"height\":50,\"caption\":\"Vishmax.com\"},\"image\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vishmax.com\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g\",\"caption\":\"admin\"},\"url\":\"http:\/\/www.vishmax.com\/en\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WordPress Redirect User after Login - Vishmax.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/","og_locale":"en_US","og_type":"article","og_title":"WordPress Redirect User after Login - Vishmax.com","og_description":"You can use the bellow code in your WordPress Theme to redirect a user after login according to the role assigned to them.Just open your function.php and copy and paste the code into it. Thats all, it will work fine with almost versions of WordPress. If any issues occured plesae inform us using comment box [&hellip;]","og_url":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/","og_site_name":"Vishmax.com","article_published_time":"2012-03-23T06:47:06+00:00","article_modified_time":"2012-05-19T10:43:26+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/#article","isPartOf":{"@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/"},"author":{"name":"admin","@id":"https:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93"},"headline":"WordPress Redirect User after Login","datePublished":"2012-03-23T06:47:06+00:00","dateModified":"2012-05-19T10:43:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/"},"wordCount":63,"commentCount":0,"publisher":{"@id":"https:\/\/www.vishmax.com\/en\/#organization"},"keywords":["Code Library","WordPress","WP Snippets"],"articleSection":["Labs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/","url":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/","name":"WordPress Redirect User after Login - Vishmax.com","isPartOf":{"@id":"https:\/\/www.vishmax.com\/en\/#website"},"datePublished":"2012-03-23T06:47:06+00:00","dateModified":"2012-05-19T10:43:26+00:00","breadcrumb":{"@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-redirect-user-after-login\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vishmax.com\/en\/"},{"@type":"ListItem","position":2,"name":"WordPress Redirect User after Login"}]},{"@type":"WebSite","@id":"https:\/\/www.vishmax.com\/en\/#website","url":"https:\/\/www.vishmax.com\/en\/","name":"Vishmax.com","description":"Websites, Hosting &amp; Full-Stack Solutions in Calicut","publisher":{"@id":"https:\/\/www.vishmax.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vishmax.com\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vishmax.com\/en\/#organization","name":"Vishmax.com","url":"https:\/\/www.vishmax.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png","contentUrl":"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png","width":150,"height":50,"caption":"Vishmax.com"},"image":{"@id":"https:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vishmax.com\/en\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g","caption":"admin"},"url":"http:\/\/www.vishmax.com\/en\/author\/admin\/"}]}},"_links":{"self":[{"href":"http:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/posts\/1147"}],"collection":[{"href":"http:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/comments?post=1147"}],"version-history":[{"count":0,"href":"http:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/posts\/1147\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/media?parent=1147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/categories?post=1147"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/tags?post=1147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}