Group Mods

  • Avatar Image
  • Avatar Image
  • Avatar Image
  • Avatar Image

Support: How-To and Troubleshooting (Support Group)

Once it’s running.

Make your own custom BuddyPress page (40 posts)

Started 1 year, 1 month ago by: John James Jacoby

← Group Forum   Support Forums
  • Avatar Image John James Jacoby said 1 year, 1 month ago:

    The title of this post makes it a little hard to grasp what I’m talking about, but in short this is a really quick and easy way to make your own hard coded BuddyPress page without going into the WordPress page admin.

    In this example we’re going to make a page called “fun” that you can visit at domain.com/fun.

    Put the following In your home theme’s functions.php file…

    define('BP_EXAMPLE_SLUG', 'fun');
    function bp_show_example_page() {
    	global $bp, $current_blog;
    
    	if ( $bp->current_component == BP_EXAMPLE_SLUG && $bp->current_action == '' ) {
    		// The first variable here must match the name of your template file below
    		bp_core_load_template( 'fun', true );
    	}
    }
    add_action( 'wp', 'bp_show_example_page', 2 );

    Now you need to create a fun.php file (mentioned above) in your home theme directory, and inside that file put…

    <?php get_header(); ?>
    	<h3>Hello</h3>
    	<p>I am an example page.</p>
    <?php get_footer(); ?>

    This could be used to make custom a custom login page, or whatever you’d like…

    All we did here was swipe the exact code BP already uses for the /register and /activate pages, and simplify it for our own use.

    Have fun!

  • Avatar Image Robert said 1 year ago:

    Thanks JJJ for the tip.
    I’ve been playing with it and it works for me only if the template page is called fun.php instead of example.php.

    Anyway I find it very useful.

    Thank you

  • Avatar Image Toly said 12 months ago:

    Robert – the example.php is meant to be replaced with whatever name you’re using for the slug/load_template.

    I’m using this to group members/groups/blogs into a community page.

  • Avatar Image Matt Kern said 12 months ago:

    Good stuff, thanks John.

    bp_core_load_template( ‘chubacabra’, true );

    that would look for chubacabra.php in the home directory, correct?

    It does not have to match the slug, I assume?

  • Avatar Image Jason Giedymin said 12 months ago:

    I like it! So simple!

    Can we should sticky this?

  • Avatar Image John James Jacoby said 12 months ago:

    @Robert, edited the post to reflect this little typo. Thanks for the catch!

    @Toly, you’re correct, but my post was still a little off. Thanks for helping clarify!

    @Matt Kern, that is correct. You can also do something like…
    bp_core_load_template( 'fun/chubacabra', true );
    …if you want to put all your chubacabra files in a directory in your themes root.

    @JasonG, we’ve got an awful lot of stickies. I’m going to add it to the Wiki instead :cough: :)

    @everyone, this method shouldn’t change much by the time BP1.1 comes around, but keep an eye out just in case.

  • Avatar Image allenweiss said 12 months ago:

    I’ve tried this, but can’t seem to get it to work. I put the function, defined above, in the functions.php page in the BP theme directory I’m using (which is the default bpmember) and put the help.php page (that’s what my page is called) into the same folder (is this correct). I think my problem is that I’m not sure when people say “home theme’s functions.php file” if they mean the bpmember folder (since that is my home theme) and if the “home theme directory” is again the bpmember folder (again, since that’s my home theme). Am I just getting this all confused?

    thanks

  • Avatar Image John James Jacoby said 12 months ago:

    @allenweiss, both of the files need to go in your active WordPress HOME theme, not your bpmember theme.

  • Avatar Image allenweiss said 11 months, 4 weeks ago:

    thanks..so if I’m using, say, carrington-blog for my wordpress home theme, then it would go in the carrington-blog directory? If so, I just tried that and it always results in a page not found. Am I doing something wrong? Note, I have the code in the functions.php file (which is in the carrington-blog folder) and the file it points to in that folder as well – as per your instructions…thanks

  • Avatar Image wordpressfan said 11 months, 3 weeks ago:

    How would I then create a new menu tab for the new page?

  • Avatar Image chewbaker said 11 months ago:

    we put this code in /wp-content/themes/bp-sn-parent/functions.php and created a page in the same directory called dashboard.php

    is there a reason why we cant navigate to the dashboard.php?

    // creates custom page----------------------
    define('BP_DASHBOARD_SLUG', 'dashboard'); 
    
    function bp_show_dashboard_page() {
    global $bp, $current_blog; 
    
    if ( $bp->current_component == BP_DASHBOARD_SLUG && $bp->current_action == '' ){
    
    // The first variable here must match the name of your template file below
        bp_core_load_template( 'dashboard', true );
       } }
    add_action( 'wp', 'bp_show_dashboard_page', 2 );
    //---------------end custom page------------------------------

    any help is appreciated!

  • Avatar Image John James Jacoby said 11 months ago:

    Are you trying to access…
    http://domain.com/dashboard/
    or
    http://domain.com/dashboard.php

    Otherwise, it looks about right?

  • Avatar Image Bpisimone said 11 months ago:

    very cool! adding this right now!

  • Avatar Image chewbaker said 11 months ago:

    Hey John,
    I’m trying to access either! neither seems to work!

  • Avatar Image Bpisimone said 11 months ago:

    Does this also work for child themes? I get at example.com/about

    This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.