[wp-hackers] Dynamic User Pages - How Does BuddyPress do it?
nikolov.tmw at gmail.com
Sat Oct 12 09:16:39 UTC 2013
You can find the sample code that I made here -
What this does is that it checks for the presence of the "member" query
variable. If it's set and is referencing a valid user, then we overload the
query and tell WordPress to load a specific page(the one taken from the
get_my_page_id() function) and we also hook to a couple of filters in order
to display the correct information.
If on the other hand it's not a valid username(at the moment - you can
change this to user ID for instance) then a 404 page is displayed instead.
There are a couple of things that you can do to improve these functions(and
you probably should):
- Make the page ID dynamic. Add an option in your plugin's settings where
the user can select which page should be the profile page(right now it's
hard-coded to 2 which is the default "Sample Page" ID).
- Allow the user to override your plugin's template. You can take a look
at how WooCommerce does it(
borrow and modify the code to fit your needs. This will basically allow the
user to create a file(for instance) "members-page.php" in their theme
directory and change the template to their liking, instead of having to
edit your plugin's file which would get over-written during an update.
If there's anything else to help with - just post it here.
On Fri, Oct 11, 2013 at 11:15 PM, BenderisGreat
<greglancaster71 at gmail.com>wrote:
> Thanks again for your help Nikola - I ended up just pasting a whole
> inside the function before and after the include statement. It works for
> now, but wont work with any other theme but mine. I was considering
> something like echo apply_filters( 'my_filter_name, $content );
> Then apply it using add_filter( 'my_filter_name',
> 'your_function_for_adjusting_the_content' ); Would something like that
> View this message in context:
> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers