Skip to content

Instantly share code, notes, and snippets.

@paulgibbs
Created August 11, 2015 22:29
Show Gist options
  • Save paulgibbs/b406efa9ca0ca4e6a3f6 to your computer and use it in GitHub Desktop.
Save paulgibbs/b406efa9ca0ca4e6a3f6 to your computer and use it in GitHub Desktop.
diff --git a/src/bp-core/bp-core-actions.php b/src/bp-core/bp-core-actions.php
index 3612378..a2e348c 100644
--- a/src/bp-core/bp-core-actions.php
+++ b/src/bp-core/bp-core-actions.php
@@ -86,11 +86,12 @@ add_action( 'bp_init', 'bp_add_permastructs', 40 );
* places. This won't always be this way, we promise.
* v---Load order
*/
-add_action( 'bp_template_redirect', 'bp_redirect_canonical', 2 );
-add_action( 'bp_template_redirect', 'bp_actions', 4 );
-add_action( 'bp_template_redirect', 'bp_screens', 6 );
-add_action( 'bp_template_redirect', 'bp_post_request', 10 );
-add_action( 'bp_template_redirect', 'bp_get_request', 10 );
+add_action( 'bp_template_redirect', 'bp_redirect_canonical', 2 );
+add_action( 'bp_template_redirect', 'bp_redirect_profile_links', 3 );
+add_action( 'bp_template_redirect', 'bp_actions', 4 );
+add_action( 'bp_template_redirect', 'bp_screens', 6 );
+add_action( 'bp_template_redirect', 'bp_post_request', 10 );
+add_action( 'bp_template_redirect', 'bp_get_request', 10 );
/**
* Add the BuddyPress functions file.
diff --git a/src/bp-core/bp-core-catchuri.php b/src/bp-core/bp-core-catchuri.php
index e0cdf60..2879f34 100644
--- a/src/bp-core/bp-core-catchuri.php
+++ b/src/bp-core/bp-core-catchuri.php
@@ -906,3 +906,34 @@ function _bp_maybe_remove_rel_canonical() {
}
}
add_action( 'wp_head', '_bp_maybe_remove_rel_canonical', 8 );
+
+/**
+ * For authenticated users, redirect URL /me/* to /members/<...>/*.
+ *
+ * Facilitates building custom menus with dynamic links to the current user's content.
+ *
+ * @since BuddyPress (2.4.0)
+ */
+function bp_redirect_profile_links() {
+ // Don't catch URIs on non-root blogs unless multiblog mode is on
+ if ( ! bp_is_root_blog() && ! bp_is_multiblog_mode() ) {
+ return false;
+ }
+
+ die(var_dump( buddypress() ));
+
+ $bp = buddypress();
+
+ if ( $bp->unfiltered_uri[0] !== 'me' ) {
+ return;
+ }
+
+ $url_parts = array_slice( $bp->unfiltered_uri, 1 );
+ array_unshift( $uri_stack, bp_get_members_root_slug() );
+
+ $uri = implode( $uri_stack, '/' );
+ $redirect_url = is_ssl() ? 'https://' : 'http://';
+ $redirect_url .= $_SERVER['HTTP_HOST'];
+
+// bp_core_redirect( $uri, );
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment