[wp-hackers] Dynamic User Pages - How Does BuddyPress do it?
BenderisGreat
greglancaster71 at gmail.com
Wed Oct 9 18:55:21 UTC 2013
Trying to dynamically create user pages (front end) without a plugin.
Similar to how buddypress does it - no custom post types for users, just
member profile urls. I tried this:
add_filter( 'query_vars', 'analytics_rewrite_add_var' );
function analytics_rewrite_add_var( $vars )
{
$vars[] = 'member';
return $vars;
}
function add_analytic_rewrite_rule(){
add_rewrite_tag( '%member%', '([^&]+)' );
add_rewrite_rule(
'^member/([^/]*)/?',
'index.php?member=$matches[1]',
'top'
);
}
add_action('init', 'add_analytic_rewrite_rule');
add_action( 'template_redirect', 'analytics_rewrite_catch' );
function analytics_rewrite_catch()
{
global $wp_query;
if ( array_key_exists( 'member', $wp_query->query_vars ) ) {
get_header();
the_content();
include_once( ABSPATH .
'/wp-content/plugins/My_Plugin/members.php');
get_sidebar();
get_footer();
exit;
}
}
But it generates the same page for every user, and even loads the page if a
random username that isnt registered is entered. How exactly does
buddypress hook into users to make dynamic pages? I am looking at the code
now, but they have so many files. Any help appreciated.
--
View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Dynamic-User-Pages-How-Does-BuddyPress-do-it-tp42492.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
More information about the wp-hackers
mailing list