{"id":4409,"date":"2022-07-13T16:02:44","date_gmt":"2022-07-13T15:02:44","guid":{"rendered":"https:\/\/ibex.tech\/wordpress-sites\/?p=4409"},"modified":"2022-07-13T16:44:43","modified_gmt":"2022-07-13T15:44:43","slug":"page-redirects","status":"publish","type":"post","link":"https:\/\/ibex.tech\/wordpress-sites\/plugins\/buddypress\/buddypress-general\/page-redirects","title":{"rendered":"Page Redirects"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Useful redirects<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/******************************************************************\n\/\/******************************************************************\n\/\/********** REDIRECT WP LOGIN PAGE TO OUR SITE HOME PAGE **********\n\/\/******************************************************************\n\/\/******************************************************************\n\/\/Fires page : \/wp-login.php\nadd_action( 'login_head', 'myplugin_add_login_fields' );\nfunction myplugin_add_login_fields() \n{\n  if (strpos($_SERVER&#91;\"REQUEST_URI\"], '\/wp-admin\/') === False)\r\n  {\r\n    wp_redirect( home_url( '\/' ) );\r\n    die();\r\n  }\n}\n\n\/\/*************************************************\n\/\/*************************************************\n\/\/********** TEMPLATE PAGE ABOUT TO LOAD **********\n\/\/*************************************************\n\/\/*************************************************\n\/\/Hook executes just before WordPress determines which template page to load. It is a good hook to use if you need to do a redirect with full knowledge of the\n\/\/content that has been queried.\nadd_action(\"template_redirect\", 'mysite_template_redirect');\nfunction mysite_template_redirect()\n{\n\n  \/\/----- LOGIN PAGE RE-DIRECTS TO USER PROFILE ONCE LOGGED IN -----\n  if ( (is_user_logged_in()) &amp;&amp; ($_SERVER&#91;\"REQUEST_URI\"] == '\/') )\n  {\n    $Username = bp_core_get_username(get_current_user_id());\n    wp_redirect( home_url( \"\/members\/$Username\/\") );\n    die();\n  }\n  \n  \/\/----- ONLY ALLOW LOGGED IN USERS TO VIEW BUDDYPRESS CONTENT -----\n  if (\n    (!is_user_logged_in()) &amp;&amp;\n    ( (strpos($_SERVER&#91;\"REQUEST_URI\"], '\/members') !== False) || (strpos($_SERVER&#91;\"REQUEST_URI\"], '\/groups') !== False) )\n  )\n  {\n    wp_redirect( home_url( '\/' ) );\n    die();\n  }\n  \n  \/\/----- MENU LOGOUT LINK -----\n  if ($_SERVER&#91;\"REQUEST_URI\"] == '\/logout')     \/\/&lt;&lt; So you can use '\/logout' as your menu logout link \n  {\n    wp_logout();\n    wp_redirect( home_url( '\/' ) );\n    die();\n  }\n\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Useful redirects<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[366],"tags":[],"class_list":["post-4409","post","type-post","status-publish","format-standard","hentry","category-buddypress-general"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/comments?post=4409"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4409\/revisions"}],"predecessor-version":[{"id":4414,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4409\/revisions\/4414"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/media?parent=4409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/categories?post=4409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/tags?post=4409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}