How to Build a Facebook-Style Members-Only WordPress-BuddyPress Site

lock

The WordPress-Buddypress-Lockdown challenge

I often read about folks wanting to lockdown their WordPress-Buddypress site, and make it so that content is accessible to logged-in members only. Even more, many want to know how to redirect site visitors to a landing page like Facebook – with login and registration on the page – while still having some select content available to them.

Look no further folks. Today, we’re gonna git ‘er done!

WordPress Buddypress - How to Make a Members Only Website (1)Once we’re finished with this project, and depending on your chosen theme of course, your landing page should look quite similar to the screenshot at right.

To make this WordPress-Buddypress project as easy as pie for even the most novice among us, this tutorial is divided into 5 parts so you can get stuff done at your leisure:

  1. Custom page template
    We need a custom page template to display the content we want site visitors to see.
  2. Landing page
    We’ll build our landing page with on-page login and registration.
  3. Logged-out menu
    We’ll create a special custom menu for site visitors.
  4. Redirect function
    We’ll write a custom function to ensure visitors can only access our selected content.
  5. Make stuff look good
    We’ll add a few style rules and tweak some stuff to get your new landing page and logged-out pages looking sharp as tacks!

Ready? Let’s dig in!

1) Custom page template

First of all, before making any of the changes described in this tutorial, I highly recommend that you be using a child-theme. If you’re not, and you’re not sure how to create one, see http://codex.wordpress.org/Child_Themes and What are Parent and Child Themes?

To make the custom template we need for visitor content, open a new document in your favorite text editor. (Do not use a word-processing program like MS-Word for this as it includes additional text formatting that will render your code useless. My +1 recommended text editor is Notepad++.)

Copy the entire contents of your theme’s page.php file to your new document. Then, insert the following code at the top, above everything else (be sure there isn’t a blank line at the top or you’ll wind up with the dreaded “Headers not sent” error when you try to use the template).

<?php
/*
Template Name: Custom Lockdown
*/
?>

Depending on the theme you are using for your WordPress-Buddypress site, there may be a lot of code in there, but your template should look something like this:

<?php
/*
Template Name: Custom Lockdown
*/
?>

<?php get_header(); ?>

/*
A lot of code in here
*/

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Since we don’t want site visitors to have access to any content other than the pages we choose, let’s make it so the sidebar and footer only display when logged-in. We’ll simply wrap the sidebar and footer calls in a is_user_logged_in() conditional, so your template will now look like this:

<?php
/*
Template Name: Custom Lockdown
*/
?>

<?php get_header(); ?>

/*
A lot of code in here
*/

<?php if (is_user_logged_in()) :?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<?php endif; ?>

If, for whatever reason you may have, you prefer to display the sidebar and footer even when logged-out, simply omit the previous step. Remember that if you do, visitors will be enticed to click on links in displayed widgets, and may get frustrated by being constantly redirected to your landing page. (Then again, you could always install a plugin to allow you to control which widgets appear when logged-in and logged-out. See this post for 10 such plugins.)

Save your new document as template-custom-lockdown.php. If you don’t like the template name I’ve suggested, simply change it to something you think is more appropriate. Remember to change the filename too though! Upload your new template to the root folder of your active child-theme.

You should now determine which pages are the only ones you want your site visitors to see. Here are some suggestions (they may not apply to your site):

  • About Us
  • Privacy Policy
  • Terms of Use
  • Membership Options
  • Features
  • Our Mission
  • …etc

In your WordPress website’s admin panel, go to “All Pages”. For each page you have selected, click the “Quick Edit” link, select your new Custom Lockdown template in the “Template” drop down menu and click “Update”. You can also use the “Bulk Edit” feature if you prefer.

Once we finish with part 4, those pages will be the only site pages logged-out visitors will have access to on your WordPress-Buddypress site. Of course, they will also have access to register.php, activate.php and wp-login.php. Oh, but wait, we need them to have access to the landing page too, right? Let’s build that now.

2) Landing page

Here’s where we take advantage of the flexibility of Buddypress components that use WordPress pages. Start by creating a new page to use as your landing page. Give it a welcoming title – maybe something like “Welcome” – add a nice image and a bit of introductory text, and click “Publish”. You do not need to assign the custom lockdown template you made in the previous step (you’ll see why in a bit). The URL for your landing page will be something like this for site visitors: yoursite.com/welcome

In your WordPress admin, go to your Buddypress settings and select the “Pages” tab. From the “Register” page dropdown, select the page you just created and click “Save”. You have now just told your WordPress-Buddypress installation that the page you created is to be used for registration. That takes care of getting the registration form to display on your landing page. Now let’s get everything else to display on that page too.

Copy the Buddypress “registration” folder from your parent theme to your child-theme. From the folder you just copied to your child-theme, open register.php. That is the template that will contain and display all your landing page content. I strongly recommend that you make a backup copy of that file, so just in case things go a bit haywire, you’ll have something to fall back on. You can call it backup-register.php and save it in the same folder.

Update: if your theme does not have a registration folder, please see this comment below.

As we want our landing page to have a similar layout as pages using the custom template we made earlier, remove the following Buddypress code from your child-theme’s register.php file. Remember to remove the corresponding closing div tags near the end of the file too, or things will go haywire!

<div id="content">
<div class="padder">

Next, we want to get the landing page content (your nice image and intro text), the login form, and the “Lost Password” link in there. We’ll be wrapping each of these elements in div containers so we can style ’em later on. We also want to put the signup form in a special div container so we can style that too. (If you do not want your users to be able to reset their passwords with the built-in WordPress function, simply omit the entire line where you see wp_lostpassword_url.) Add the following code just above where you see <form action=””. Then add a closing </div> tag just after the closing </form> tag.

<div id="my-custom-home">
<?php the_post(); ?>
<?php get_template_part( 'content', 'page' );?>
</div>

<div id="my-custom-login">
<h2><?php _e( 'Login Here', 'buddypress' ) ?></h2>
<?php wp_login_form(); ?>
<a href="<?php echo wp_lostpassword_url( get_permalink() ); ?>" title="Lost Password">Lost Your Password?</a>
</div>
<div id="my-custom-registration">

Note that the code above applies to more recent themes that use template parts. If your theme does not use template parts, see the comments below for an easy solution.

The last thing we want to do in register.php is hide the sidebar and footer like we did in our custom template. Replace the calls to the sidebar and footer with the respective code bits below. Again, if you don’t want to, don’t.

<<?php if (is_user_logged_in()) :?>
<?php get_sidebar( 'buddypress' ) ?>
<?php endif; ?>
<?php if (is_user_logged_in()) :?>
<?php get_footer( 'buddypress' ) ?>
<?php endif; ?>

Save the register.php file and upload it to the registration folder of your child-theme.

Great stuff! We now have our landing page set up with login and registration forms on the page, and a bit of introductory content to boot. We’ve also selected the pages site visitors have access to, and have assigned our Custom Lockdown template to all of those.

Go ahead and test stuff out now to make sure it works properly before we go any further. Be sure you’re logged-out of your site, then navigate to your landing page url. Don’t worry about how it looks just yet. Let’s be sure all the functionality is there first. Done? Good.

3) Logged-out menu

Now let’s create a logged-out menu for your WordPress-Buddypress site with links to all logged-out-authorized pages only. We need to do only 2 things to create the new menu:

  • register the new menu in your child-theme’s functions.php file
  • call the new menu in the right spot, and under the right conditions, in the child-theme’s header.php file

Open your child-theme’s functions.php file now. If it doesn’t have one yet, create it now (see this page for more on this file in child-themes).

Now open your parent theme’s functions.php file and locate the function that has register_nav_menu in it. It will look something like this:

if ( ! function_exists( 'theme_register_menus' ) ) :
function theme_register_menus() {
	register_nav_menu('top_menu', __('Top Menu', TEMPLATE_DOMAIN));
}
endif;

Copy that entire function to your child-theme’s functions.php file. Now copy the line that has register_nav_menu in it, and paste it directly beneath that line. You should have 2 identical lines, one after the other. In one of them – it doesn’t matter which one – change both occurrences of the name of the menu to something you’ll recognize as your logged-out menu (remember to separate words in the 1st occurrence with underscores). Perhaps simply call it Logged-Out Top Menu. Your function should now look something like this:

if ( ! function_exists( 'theme_register_menus' ) ) :
function theme_register_menus() {
	register_nav_menu('top_menu', __('Top Menu', TEMPLATE_DOMAIN));
	register_nav_menu('logged_out_top_menu', __('Logged Out Top Menu', TEMPLATE_DOMAIN));
}
endif;

Save your functions.php file and upload it to the root of your child-theme. You now have 2 different menus registered in your child-theme. As we are declaring the same function that exists in the parent-theme, it replaces that function (which is why we register the original menu again in the child-theme). If you visit Appearance > Menus in your site’s backend, you’ll see in the Theme Locations box at top-left that Your theme supports 2 menus. See it? Great!

While you’re there, you may as well take a moment to create your new logged-out menu (we’ll get it to display in a moment). Create a new menu and add all the pages you had earlier assigned your Custom Lockdown template to. Also add the page you had earlier assigned for registration in your Buddypress settings – i.e.: your landing page. You may want to give that one an easy-to-recognize navigation label, like Login or Signup. Save your menu, select it for your logged-out menu in the Theme Locations box, and save there too.

Now we want to get that new menu to appear in the right spot in the header, but only display when logged-out. In other words, our new menu will appear when logged-out (your original menu will not be called), and it will be replaced by your original menu when logged-in.

Open your child-theme’s header.php file. If it doesn’t exist yet in your child-theme, simply copy the one from the parent to the child. Search your child-theme’s header.php until you find the call for wp_nav_menu. It will look something like either example below:

<?php wp_nav_menu( array(
	'theme_location' => 'top_menu',
	'menu_class' => 'topmenu',
	'container' => '',
	'fallback_cb' => 'theme_fallback_menu'
)); ?>
<?php wp_nav_menu( array('theme_location' => 'top_menu', 'menu_class' => 'topmenu', 'container' => '', 'fallback_cb' => 'theme_fallback_menu')); ?>

Copy that entire snippet and paste it directly beneath so you have 2 identical snippets, one on top of the other. The only thing we want to change here is the value for theme_location in the 2nd one. Locate that value in the 2nd snippet, and replace it with the value we gave to the new menu we created above. In the above example, we called it logged_out_top_menu.

Now we’re going to wrap those 2 menu calls in a conditional so that the 1st one appears only when logged-in, and the 2nd appears only when logged-out. Paste the following code before the 1st menu call:

<?php if (is_user_logged_in()) :?>

Then add this between the 2 calls:

<?php else: ?>

Finally, add the following after the 2nd menu call:

<?php endif; ?>

Your entire code for both menu calls should now look something like this example:

<?php if (is_user_logged_in()) :?>
	<?php wp_nav_menu( array(
		'theme_location' => 'top_menu',
		'menu_class' => 'topmenu',
		'container' => '',
		'fallback_cb' => 'theme_fallback_menu'
	)); ?&gt
<?php else: ?>
	<?php wp_nav_menu( array(
		'theme_location' => 'logged_out_top_menu',
		'menu_class' => 'topmenu',
		'container' => '',
		'fallback_cb' => 'theme_fallback_menu'
	)); ?&gt
<?php endif; ?>

We have now registered both a logged-in and a logged-out menu in the child-theme’s functions.php file, have created the new logged-out menu in our site’s backend, and have set up the header.php file so that each menu appears only when the correct condition is met.

4) Redirect function

Now it’s time to create the function that will ensure that site visitors – i.e.: logged-out – will be able to access only the pages we have added to our new logged_out_top_menu, our landing page (register.php), as well as activate.php and wp-login.php (for password recovery).

Open your child-theme’s functions.php file again. Paste the following code directly after the opening <?php tag:

add_action( 'wp', 'custom_lockdown_redirect', 3 );
function custom_lockdown_redirect(){
global $wp;
	if (!is_user_logged_in()){
	if ( bp_is_activation_page()
		|| bp_is_register_page()
		|| is_page_template( 'template-custom-lockdown.php' )
		|| ( in_array( $GLOBALS['pagenow'], array( 'wp-login.php' )))
		)
	 return;
		bp_core_redirect(get_option('siteurl') . "/welcome");
		exit;
		}
	}

If you have used the example filename I gave above for the Custom Lockdown template (template-custom-lockdown.php), and the example page slug for the landing page (welcome), the redirect function will work as-is. If you have changed those in any way, you will need to edit the above function so it contains the proper names.

Once you have edited the function with your file and page names (if necessary), save your functions.php file and upload it again to your child-theme. To test the function, be sure you’re logged-out of your site. If you’re already logged-out, simply refresh the page (you may need to clear your browser’s cache also). If all is well, you should see only your logged-out menu appear in your site’s header.

Click each link to be sure you can get to it when logged-out. Now try to get to any other page or url on your site. You should be redirected to your new landing page. Fun, huh?

5) Make stuff look good

Now for the final bit: let’s add a bit of simple css magic to make your WordPress-Buddypress landing page look snappy! If you have used the example names I gave for the wrapper divs in part 2 (Landing page), the following css will pop your landing page right into shape. Add the following to your child-theme’s style.css file. (If you’re using a theme from WPMUdev.org, you’ll likely want to edit the _inc/css/child-style.css file instead.)

/*LANDING PAGE*/
#my-custom-home {
  float:left;
  }
#my-custom-home .post-body img{
  max-height:212px;
  width:auto;
  }
#my-custom-home h1.post-title, #my-custom-home .post-meta {
  display:none;
  }
#my-custom-login {
  float:right;
  background:#eee;
  padding:1em;
  }
#my-custom-registration {
  float:left;
  width:100%;
  }
#my-custom-registration h2 {
  background:#eee;
  margin:2em 0 0.5em;
  padding:0.5em;
  }

WordPress Buddypress - How to Make a Members Only Website (1)Save your style.css file and upload it to your child-theme. Now, still logged-out of your site, refresh your landing page and everything should pop right into shape as in the example image at the top of this page. Here it is again just for convenience.

If you’re using a responsive theme, you may want to tweak things a bit to get the landing page looking all nice and pretty on smaller devices. If you’re not sure how to write specific style rules for various devices and capabilities, check out this great article from SmashingMagazine.com, or search Google for how to use css media queries.


I hope you enjoyed this tutorial on building a members-only WordPress-Buddypress site, and find use for it! If you need any help with any part of it, or want to show off the results of your efforts, please leave a detailed comment below (with a link to your site if possible). Thanks for reading!

Photo credit: Flickr.com

216 Responses

      Anaske Assefa

      this is greate, but i cant find the “register_nav_menu’ my parent theme’s functions.php . for some reason it is not there. i am using buddypress.Version 1.5.7

      Please any help

            Patrick Cohen

            Heya Campuss Page,

            You’re gonna have to be a bit more explicit than that. Just saying the page cannot load doesn’t tell me anything.

            Which page doesn’t load?
            Do you get any error messages in the browser?

            Campuss Page

            ok, my bad. i didnt give all the info. first am using a bp child theme called bp columns. i didnt find the “root file” so i just created one by just inserting a new folder. when i insert all the other codes to where you said, i get a reply from google chrome saying the page cannot load since it has resulted to too many redirects so i have to clear the cache and even when i do so, no thing happens. i had to remove the child theme and re install it afresh. i also have another issue disterbing me. my site is a social networking site but cannot be seen through the phones. i have tried the wordpress mobile sites but nothing is happening. i have tried dudamobile but i cant be able to set it up so that visitors can directly be redirected to the login form instead of what is showing. do you have any idea on hat i can do so that my site can be mobile? i would also like it to show activity stream just like facebook and tweeter. you can check my site to see what i mean.

            Yaseen Salim

            hi there. i was still waiting for the answer. i have changed the child theme to frisco and it is helping me with the mobile issue but the loading speed is slow and when someone trie to access it through the mobile, it gives a warning that only admin is supposed to use the mobile site.

        Campuss Page

        Hi Patrick, i dont know if you have been seeing my messages. i am now using the frisco theme to see if the mobile issue can be solved. luckily it has but not all of it. the problem is finding the ‘page.php’ file which isnt there. i dont know what i can do about it. do you have any clue how i can design a nice landing page just like the one you have discussed here using my frisco theme?

    snapalot

    Our team built our company’s intranet with buddypress and are getting ready to launch.

    Reading this post makes me consider making a few changes however. We currently use Private BuddyPress and My Brand Login plugins for “lockdown”.

    Using Patrick’s methods would provide a friendlier introduction, but I wonder how the registration would work. I was hoping to use Invite Anyone, but in combination with Private Buddypress the process gets interrupted.

    My plan B is bulk importing the members, but then the members cannot choose their passwords.

    Anyway, thank you for the post Patrick!

      Patrick Cohen

      Hi Kobus,

      Because we’re using register.php as the landing page template, the registration process is not interrupted, and works as it was designed to. So, no worries there.

      The Invite Anyone plugin should also work fine with this method.

      As for bulk importing members, yes, they can choose their passwords. Instruct your members (perhaps in a welcome email) to reset their given passwords in their BuddyPress profile once they have logged in with the passwords you give them.

      Another option you may want to consider for branding the wp-login page is WPMUdev’s own super-simple Login Image plugin: http://premium.wpmudev.org/project/login-image/

      Hope this helps!

      Patrick Cohen

      Hi Aliyah,

      What browser issue are you getting? Can you be more specific?

      If your text & image don’t show up, then your theme is probably not using “template parts”. In the code supplied above for the landing page, try replacing…

      get_template_part( ‘content’, ‘page’ )

      …with this

      the_content()

      That should clear it up.

      Patrick Cohen

      Glad you got it sorted!

      I’m off to the country for the weekend where I only have a maddeningly slow dial-up connection, so if you need more help, I may not be back online until Sunday evening.

      Have a great weekend!

      Patrick Cohen

      Hi!

      The redirect function, as given above, will lock visitors out of your main site only. They will still have access to sub-sites in your network.

      Hope this helps! :-)

          Patrick Cohen

          If you mean the Balance theme by StudioPress, then that would be a child-theme of the Genesis Framework, right?

          So, then you need to look in the functions.php file of the parent theme (Genesis) for the register_nav_menu function. Copy that entire function to the child-theme (Balance) functions.php, and make the mods as in Step 3 above.

          Should get you going. :-)

            PONKO

            Ah! Infinity is a whole other beast entirely. Infinity has a rather novel design and nav menus are registered and defined in ways that I’m not too familiar with.

            Your best bet would be to contact Marshall or Bowe directly through their support forums: http://community.presscrew.com/discussion/premium-plugins/

            Ask them how to register a new, logged-out-only main-menu in the Balance child-theme. Give them a link to this page so they can fully understand what you are trying to accomplish.

            Hope that helps! :-)

            Marshall Sorenson

            For any Infinity or Balance users who happen upon this comment, Patrick’s tutorial is 100% compatible with our themes. Although we do some tricky stuff internally, there is nothing stopping you from customizing the themes using standard WordPress API functions, just like Patrick has done here. In fact, we call the exact same API functions behind the scenes.

            Really great tutorial Patrick! And thank you for fielding questions about our themes. Very professional! :)

      Patrick Cohen

      I’m surprised that they didn’t answer your query. Once you find another theme that suits you, please let me know if you need more help. I’ll gladly try to walk you through any difficulties.

      :-)

    blogmylunch

    I have a question about this on the forums..because the functions file for infinity is not the same in balance and I wasn’t able to complete the customization. Aside from that, even if I had, the way I had to update the theme by erasing everything and reinstalling, I’d have to do it all over again now.

      Bowe Frankema

      Hi There,

      I think you are a bit confused on how the update process works. When a new version of Balance comes out you can just upgrade the parent theme and keep all the changes you have made in your child theme. This is exactly why we ship all of our themes with a pre-made Child Theme. If you implement Patrick his tutorial in your child theme there is no way of losing your changes during updates :-)

      Just make sure to copy over the templates to your child theme and not make any changes to the parent. So if Patrick says “Edit header.php”, first copy over “header.php” to your Balance Child theme and then make the according changes.

      Regarding us not paying any attention to your support question. I’m sorry you feel that way, but we do try to handle support as quick as possible while still implementing new features and bug fixes based on community feedback. Sometimes this means you’ll have to wait a little longer before we can look at these requests.

      @Patrick: Really cool to see you posting these tutorial here on WPMU. This is a common request and this is a solid write-up. Cheers!

      Bowe Frankema

      Patrick does not say to copy the entire file. He says to copy part of the functions.php ie; the register menu function. Like I’ve told you on our support forums all the above can be achieved by following the tutorial. If you get stuck you can always ask a developer to do it for you. It just falls outside of the theme support we normally do.

      That being said I’ll try add this functionality to our themes in the future, so you can enable a logged out menu from your theme options page :-)

      Patrick Cohen

      @Bowe @Marshall

      I had loads of fun with Infinity last year when I bought a test copy to play with. But I do have a bit of difficulty getting my head around the “tricky stuff”, specifically the Walkers (don’t understand that bit yet as I still consider myself a php n00b).

      And thanks for the compliments guys. Coming from 2 designers who do command respect in the WP arena, it’s high praise indeed :-)

    Mark West

    Hi Patrick,

    Thanks for the great post! One place I am stuck at is the logged out menu. The snippets”register_nav_menu” you have us search for don’t exist in my functions.php file. All I see that is similar is:

    if ( !function_exists( ‘bp_dtheme_page_menu_args’ ) ) :
    /**
    * Get our wp_nav_menu() fallback, bp_dtheme_main_nav(), to show a home link.
    *
    * @param array $args Default values for wp_page_menu()
    * @see wp_page_menu()
    * @since BuddyPress (1.5)
    */
    function bp_dtheme_page_menu_args( $args ) {
    $args[‘show_home’] = true;
    return $args;
    }
    add_filter( ‘wp_page_menu_args’, ‘bp_dtheme_page_menu_args’ );
    endif;

    Any ideas? I am using buddypress 1.6

      Mark West

      oppps. Wanted to paste this code:

      if ( !function_exists( ‘bp_dtheme_main_nav’ ) ) :
      /**
      * wp_nav_menu() callback from the main navigation in header.php
      *
      * Used when the custom menus haven’t been configured.
      *
      * @param array Menu arguments from wp_nav_menu()
      * @see wp_nav_menu()
      * @since BuddyPress (1.5)
      */
      function bp_dtheme_main_nav( $args ) {
      $pages_args = array(
      ‘depth’ => 0,
      ‘echo’ => false,
      ‘exclude’ => ”,
      ‘title_li’ => ”
      );
      $menu = wp_page_menu( $pages_args );
      $menu = str_replace( array( ”, ” ), array( ”, ‘ ‘ ), $menu );
      echo $menu;

      do_action( ‘bp_nav_items’ );
      }
      endif;

    Patrick Cohen

    Hiya Mark,

    I see you’re using the bp-default theme (I hope you are using a child-theme though!).

    The code you’ve shown above is for the fallback menu that displays in case no custom menus have been set up in your WP backend (i.e.: it displays default pages such as Activity, Members, Groups, etc.).

    You should see a line in functions.php BEFORE that code that looks something like this:

    // This theme uses wp_nav_menu() in one location.
    register_nav_menus( array(
    ‘primary’ => __( ‘Primary Navigation’, ‘buddypress’ ),
    ) );

    That code is part of the following function:

    function bp_dtheme_setup()

    You’ll need to copy that entire function to your child-theme’s functions.php file from
    function bp_dtheme_setup() {
    …all the way to
    add_action( ‘after_setup_theme’, ‘bp_dtheme_setup’ );

    Then modify the register_nav_menus part like this:

    // This theme uses wp_nav_menu() in two locations.
    register_nav_menus( array(
    ‘primary’ => __( ‘Primary Navigation’, ‘buddypress’ ),
    ) );
    register_nav_menus( array(
    ‘logged-out’ => __( ‘Logged-Out Navigation’, ‘buddypress’ ),
    ) );

    Then, modify the call to wp_nav_menu in your child-theme’s header.php file as per the instructions in the tutorial.

    Hope this helps! :-)

      Mark West

      Thanks Patrick! That worked perfectly. I am close….but i added the redirect function and i am now getting infinite redirect loop error. I know this is a tough error to figure out…any guesses? I followed your naming convention.

      Thanks,
      Mark

    Patrick Cohen

    Hi Mark,

    Sorry for taking so long to get back to you on this.

    Do you have any plugins activated on your site that perform any kind of redirect when logged out? There may be a conflict.

    Try removing the following snippet from the redirect function. We’ll work from there. Doing so should redirect logged-out users to your welcome page no matter what.

    if ( bp_is_activation_page()
    || is_page_template( ‘template-custom-lockdown.php’ )
    || ( in_array( $GLOBALS[‘pagenow’], array( ‘wp-login.php’ )))
    )

    Mark West

    Thanks for the reply Patrick. So i commented out those line and the error goes away.

    Also tried rebuilding a new site that had just wordpress and buddypress and followed the tutorial again and I arrived at the same error. Any ideas what would cause this?

    Patrick Cohen

    Hi Mark,

    We’re off to a good start here. Without the conditional pages in the redirect function, you’re redirected to your Welcome page when logged-out, right? That would indicate that the problem is with one or more of those conditionals.

    The first thing that comes to mind is: be sure you have NOT assigned the Custom Lockdown template to your Welcome page. That would definitely cause a redirect loop.

    Also, be sure that template is NOT used on whichever page you have assigned to the “Activate” page in your BP settings… might confuse WP, ya never know :-)

    Lemme know how that goes :-) (Gotta get to work now!)

      Mark West

      Actually no it’s not redirecting to the welcome page. I can access the welcome page but its redirecting to the root of the domain or http://www.example.com.

      To remove all complications I am doing this on the clean install with only buddypress and wordpress installed. The only pages are the default ones. So custom lockdown is only assigned to “Sample Page”.

      The redirect sends us to the “home” page where the “Hello world” post is. Before you have us set up the menu in step 3, “home” shows up as a tab (I deselected it from the primary and lockdown menu).

      Thanks,
      Mark

    Mark West

    Update: So figured out how to get it to redirect to welcome when the code is commented out. Hadn’t set this instance to have a static home page rather than last post.

    Still can’t get the redirect loop to work however.

      Mark West

      So I have done quiet a bit of trouble shooting and here is what I have learned:

      1. When I comment out the 4 lines you recommend above the redirect error goes away and i am taken to the site home page (whatever is configured at Settings>Reading>Static Page). If I set this to welcome it loads fine. I did notice when it loads its loading purely http://www.example.com not example.com/welcome. Which leads me to believe the If user is not logged in function is not being evaluated (yep I’m logged out triple checked) or the return redirect piece is failing.

      2. Checked the pages for registration (in this case welcome) and activation and both have the default templates applied.

      3. Tried switching the redirect function to the wordpress core one with the same infinite redirect error.

      4. Removed the first if (if is not logged in) and i get the same redirect error.

      Any ideas? Am I missing something? Thanks for your help.

    Patrick Cohen

    Hi Mark,

    Good debugging! Here are my suggestions:

    1) Configure Settings > Reading to any page OTHER than your welcome page. This can be any other page and can use any template because it will only be called when the user is logged in. (Whichever page you set here, the url will always be http://www.example.com) Then add the bp register page to the list of allowed urls in the lockdown function as follows:

    add_action( ‘wp’, ‘custom_lockdown_redirect’, 3 );
    function custom_lockdown_redirect(){
    global $wp;
    if (!is_user_logged_in()){
    if ( bp_is_activation_page()
    || bp_is_register_page()
    || is_page_template( ‘template-custom-lockdown.php’ )
    || ( in_array( $GLOBALS[‘pagenow’], array( ‘wp-login.php’ )))
    )
    return;
    bp_core_redirect(get_option(‘siteurl’) . “/welcome”);
    exit;
    }
    }

    2) You could try modifying the redirect with either of the following:

    bp_core_redirect( $bp->root_domain .’/’. BP_REGISTER_SLUG );

    bp_core_redirect( $bp->root_domain .’/’. ‘welcome’ );

    Hope this helps! :-)

    Fabam Paul

    @blog my lunch, put this in your function

    /*Buddypress profile as homepage */
    function bp_profile_homepage()
    {
    global $bp;
    if(is_user_logged_in() && bp_is_front_page())
    {
    wp_redirect( $bp->loggedin_user->domain );
    }
    }
    function logout_redirection()
    {
    global $bp;
    $redirect = $bp->root_domain;
    wp_logout_url( $redirect );
    }

    add_action(‘wp’,’bp_profile_homepage’);
    add_action(‘wp_logout’,’logout_redirection’);

    Paul Ford

    In step two you instruct us to remove the following Buddypress code from the child-theme’s register.php file:

    I do not see anywhere in the register.php file. However I do see . The file I am using is register.php originally from /public_html/mysite.com/wp-content/plugins/buddypress/bp-themes/bp-default/registration

    What am I doing wrong here? I am running WP 3.4.1, and BuddyPress 1.6.1

      Paul Ford

      Ok, the code from my above comment was removed. I’ll try this again:

      In step two you instruct us to remove the following Buddypress code from the child-theme’s register.php file:

      ..
      ..

      I do not see .. anywhere in the register.php file. However I do see . . The file I am using is register.php originally from /public_html/mysite.com/wp-content/plugins/buddypress/bp-themes/bp-default/registration

      What am I doing wrong here? I am running WP 3.4.1, and BuddyPress 1.6.1

      Paul Ford

      Ok, one more time!

      In step two you instruct us to remove the following Buddypress code from the child-theme’s register.php file:

      div class=”content”
      div class=”padder”

      I do not see div class=”content” anywhere in the register.php file. However I do see div id=”content” . The file I am using is register.php originally from /public_html/mysite.com/wp-content/plugins/buddypress/bp-themes/bp-default/registration

      What am I doing wrong here? I am running WP 3.4.1, and BuddyPress 1.6.1

        Patrick Cohen

        Hi Paul,

        Having trouble posting code I see ;)

        You are absolutely right though; div class=”content” doesn’t exist… my bad. Typo corrected. Thanks for spotting that!

        The correct instructions are to remove the following:

        div id=”content”
        div class=”padder”

        … as well as corresponding closing tags, of course.

    Paul Ford

    Stuck on step 3. Your instruction: open your parent theme’s functions.php file and locate the function that has register_nav_menu in it. It will look something like this: (code omitted)

    What is the path to the correct parent theme functions.php?

    I’ve looked at the one located in the root at /public_html/mysite.com/wp-content/plugins/buddypress/bp-themes/bp-default/functions.php. There’s no matching code for register_nav_menu in this file.

    Paul Ford

    One thing to point out about an item in Step 3, your instructions: If you visit Appearance > Menus in your site’s backend, you’ll see in the Theme Locations box at top-left that Your theme supports 2 menus. See it? Great!

    You will not see a Theme Locations box unless you actually have a menu created. So, if the box is not there, create a test menu … then the Theme Locations box will show & you’ll then be able to see that your theme supports 2 menus.

    Paul Ford

    I’m so close! Everything is working, but I’m having trouble with the landing page format. I used your fix above: replacing… get_template_part( ‘content’, ‘page’ ) …with this: the_content()

    Right now my Image and welcome text is on the left, the form is in the center and the “Login Here” box is on the right. UNLIKE your screen shot where the form is underneath your welcome image and welcome text and login box. Any Ideas? css?

    Also do you have your site on line so I can inspect the elements and compare to mine?

        Patrick Cohen

        Hey Paul,

        Sorry I didn’t get back to you sooner on this; was offline for the weekend.

        Do you have a link to your site so I can take a look? If not, can you post a screenshot of what you have now, and let me know what theme you’re using?

        I’ll see if I can help you over this last hump :)

            Patrick Cohen

            Hi again Paul,

            Thanks for the link. I see where things screwed up (my bad again, dammit).

            I had indicated the wrong place to insert the my-custom-home, my-custom-login and my-custom-registration divs. All 3 should be inserted one after the other, right before the registration form.

            I’ve updated Step 2 above to reflect this (I’m surprised no else reported it). You should be good to go with the rest. ;o)

            Paul Ford

            You know what would be the cherry on top … If I could force new registrations to require an administrators approval before granting access to the site.

            If you know of a way to do that then all my problems would be solved.

      Patrick Cohen

      Hi Lesego,

      I don’t own a copy of BuddyBoss, so I can’t see the actual code in the files. But I took a look at your registration page in Firebug: http://www.royaltweet.com/welcome-to-royaltweet/

      It looks like the code for Step 2 above would be best inserted just before

      div id=”login”
      …form stuff here…
      /div

      Don’t forget to add a closing div tag after the closing tag for the “login” div.

      Hope this helps! :)

    leseg___keikabile

    Thank You For The Previous Reply
    I have an issue In locating Codes. So I found it not appropriate to paste all codes here, I guess it will look ugly having long codes here, so I pasted on a notePad and Uploaded on ROYALTWEET

    URL:{http://www.royaltweet.com/?attachment_id=293}

    Step2.Landing page

    In BuddyBoss I can not locate this two codes’ so It is way to hard for me to change the layout

    3) Logged-out menu

    And I am trying to lacate bellow code… Its way different too

    if ( ! function_exists( ‘theme_register_menus’ ) ) :
    function theme_register_menus() {
    register_nav_menu(‘top_menu’, __(‘Top Menu’, TEMPLATE_DOMAIN));
    }
    endif;

      Patrick Cohen

      Hi again Lesegõ,

      Sorry, the link you posted to view the code on your site results in an endless redirect so i can’t see it. Could you post the code you’re having trouble with to http://pastebin.com/ instead?

      For the logged-out menu, all you really need to locate is the line where you see register_nav_menu. Copy that line, paste it again immediately below, then change the menu name in the one you just pasted.

    leseg___keikabile

    After pasting register_nav_menu. I am geting a Syntax Error.

    “Parse error: syntax error, unexpected ‘<' in /home/lkckeid0/public_html/royaltweet.com/wp-content/themes/buddyboss/functions.php on line 117"

    this is what I did:
    ________________________________________________________

    register_nav_menus( array(
    ‘primary-menu’ => __( ‘Primary Menu’ ),
    ‘secondary-menu’ => __( ‘Footer Menu’ ),
    ‘profile-menu’ => __( ‘Profile Sidebar’ ),
    ‘group-menu’ => __( ‘Group Sidebar’ ),
    ) );

    register_nav_menus( array(
    ‘primary-menu’ => __( ‘Primary Menu’ ),
    ‘secondary-menu’ => __( ‘Footer Menu’ ),
    ‘profile-menu’ => __( ‘Profile Sidebar’ ),
    ‘group-menu’ => __( ‘Group Sidebar’ ),
    ) );

      Patrick Cohen

      @Lesegõ

      What exactly would you like to do to the layout? Can you create a mockup of what you’d like, upload it to a sharing site like tinypic.com and post a link here so I can see what you’re looking for?

      What issues are you having with hiding pages from unregistered users?

    leseg___keikabile

    Thank You For Your Response.

    I was thinking maybe I could rearrange textBox Horizontally , three on the left and two right with left alignment, so it is giving me a hard time to do it, if you could go to the website and click submit on a registration form you ll see that there is a problem with the layout form… I am not sure whether its the container or what…

    Another thing, how do i add text on the left of the loginForm, just like The Picture you shared? [www.royaltweet.com]

    I have uploaded an image i hope you can see it, i used free hand drawing

    http://tinypic.com/r/tz2w9/6

      Patrick Cohen

      @Lesegõ

      You can’t really put only 3 input boxes on the left and 2 on the right because 4 of them are in the basic-details-section div container. So, to put basic details on the left, and profile details on the right, add the following to your style-sheet:
      `
      #my-custom-registration form.standard-form #basic-details-section,
      #my-custom-registration form.standard-form #profile-details-section,
      #my-custom-registration form.standard-form #blog-details-section,
      #my-custom-registration p.signup-submit {
      clear:none;
      float:left;
      margin:10px;
      width:48%;
      }
      `
      I highly recommend learning how to use your browser’s developer tools to inspect page elements. It will make CSS customization a lot easier for you :)

      To get some welcome text in there, please review 2) Landing page. You simply add whatever you want to the page you selected as your landing page (welcome-to-royaltweet).

      Hope this helps! :)

    leseg___keikabile

    It works. Almost everything works. But i think something is still missing and i dont know what it is… The registeration form looks a bit awkward, if you click on submission button without filling up your details, the error lines and text boxes looks weird. :-O

    I was thinking maybe i could resize textbox to suit the container but my coding skills is a bit lacking

    Patrick Cohen

    @Lesegõ,

    You’re quite right. I forgot to include the CSS for your text boxes in my previous reply, sorry. Add the following to your style-sheet; it should get the text inputs nicely re-sized, and aligned with the error messages.

    #my-custom-registration form.standard-form #basic-details-section input[type=”password”],
    #my-custom-registration form.standard-form #blog-details-section input#signup_blog_url,
    #my-custom-registration form#signup_form.standard-form input[type=”text”],
    #my-custom-registration form#signup_form.standard-form textarea {
    width:90%;
    }

    Hope this helps! :)

      Patrick Cohen

      Hi again Lesegõ,

      If you want to make your footer extend the full-width of the screen like your navigation bar, try adding the following to your style-sheet:

      #footer {
      position:absolute;
      left:0;
      }

      Hope this helps! :)

        leseg___keikabile

        Thank you once Again.
        It didnt work, so i came up with a simple solution, i changed the colour to make the footer look like body and background just making thing look a bit even. But I am still strangling on putting a welcome text. I have been try to follow exactly what you provided there, but i don’t know what i am missing on your steps.

    Tom Addis

    Hi Patrick, superb post! It’s the only one out there to help Buddypress developers.

    I have a quick question:

    I’m using a child theme and at the end of step two I have successfully set up the new custom registration page and changed the settings in BP > Pages to make this the default registration page.

    My big problem is that if I log out and navigate to the home URL I still get the full home page, and I’m able to access all the content.

    Does this mean that my child theme is using a page other than page.php as its landing?

    Any advice gratefully received! Thanks again.

    Tom

    peter_jakobsen

    Hi Patrick,

    I tried hard to make your tweaks working with membership. I had no problem with just buddypress. The problem started when I turn membership on. There is a conflict between Membership registration and the buddypres registration. I found a solution and it is easy:-)

    You only need to go though step 1 and step 4 – the membership software take care of the rest.

    Explanation:
    In step 2 membership have the landing page and take care of registration.
    Step 3. You design menu outside in membership.
    Step 4. The edit membership form in css, if needed.

    Oh. This took some time to figure out. So here have it.

    Regards,

    Peter

        peter_jakobsen

        Hi Poul,

        Yes, here is the link to my site: http://www.trylleskolen2.dk/forsiden/. This is just a test-URL. I already have more than 3500 members on my old membersite, so I have to be sure everything is working perfect before launch and when it is ready I’ll write the URL here.

        The registration-page is http://www.trylleskolen2.dk/start The visitors will not see Memberships-registration-page anywhere. On the homepage there will be links to two different levels – one the free access level and one for the paid level. Another visitors get to the last part of the registration-process: ?action=registeruser&subscription=2

        Figuring out membership is a puzzle, but when you get a hang of it, it is absolutely brilliant. And your tweaks on this blog are very useful and cool. You should get them in the membership-manual.

    Martin Low

    My best Christmas gift this year will be having Patrick to clean up all the steps and provide the respective customized files for Frisco BP child theme where all I do is copy and paste ;)

    Z Panda

    First of all, thank you so much! I’m building a community learning platform for a non-profit and this was exactly what I needed. I’ve learned so much from this post alone.

    I’ve seem to have everything working, except for one thing. After step 4 every single page redirects to welcome.html. I’m using a child theme for buddypress default them and have followed the function exactly. The logged out nav bar does show up…it’s that when you click on the any of the links they redirect to welcome.html. I’ve tried changing the pages to several default templates and it still doesn’t seem to be working. Any thoughts would be greatly appreciated.

      Patrick Cohen

      Hiya Z!

      Glad you found this educational :)

      Did you assign your custom lockdown template to each page accessible to logged-out users? Trying to access pages using any other template will result in being redirected to your welcome page.

        Z Panda

        wow. thank you! I somehow had it backwards. Where everything with the template would be private. I also had a – instead of a _ in the code. Thank you again!

    Hamed Hemmati

    Hi Patrick this is exactly what I was looking for. Is there any way to do the password reset on the same page rather than going to the WordPress password reset page?

    I have the site localized in different languages and the WordPress password reset page can only be shown in the default language which is a problem.

    leseg___keikabile

    Hello Patrick . I need help… I have created a separate page ( not login.php or register.php) which i am using as a front page…

    With the help of custom-locked-down template. Everything is just perfect excepted one thing, I want the page to be accessed by logged out users only.
    With the custom-locked-down the logged out user will be redirected to the front page, is there a way to modify the code, just that when you are logged in and try to access the front page you ll be redirected to somewhere else. [RoyaltweetDotCom]

      PONKO

      Hi Lesegõ,

      Try adding this to your functions.php file. Change frontpage-slug-here and redirect-to-slug-here to the slugs of your actual pages. Should do the trick.

      add_action( 'wp', 'custom_loggedin_redirect', 3 );
      function custom_loggedin_redirect(){
      global $wp;
      if (is_user_logged_in() && is_page('frontpage-slug-here'));
      bp_core_redirect(get_option('siteurl') . "/redirect-to-slug-here");
      exit;
      }

    leseg___keikabile

    Thank you for you response,

    This is what i did:
    add_action( ‘wp’, ‘custom_loggedin_redirect’, 3 );
    function custom_loggedin_redirect(){
    global $wp;
    if (is_user_logged_in() && is_page(‘siteurl’));
    bp_core_redirect(get_option(‘siteurl’) . “/home”);
    exit;
    }

    It is not redirecting properly, infect, it seems like every pages is redirecting to home… And i get too many redirect message on a browser

      Patrick Cohen

      Hi again Lesegõ,

      The code you show above is definitely not going to work. The way you’ve entered these lines:
      if (is_user_logged_in() && is_page('siteurl'));
      bp_core_redirect(get_option('siteurl') . "/home");

      …you’re telling the browser that, no matter where the logged-in user is on your site, redirect him to “/home”, even if he’s on the homepage; infinite redirect.

      In the code I gave above, change frontpage-slug-here to the slug of the page you set as your not-logged-in homepage.

      Then change redirect-to-slug-here to the slug of the page you want to redirect logged-in users if they try to access your not-logged-in homepage.

      If you’re not sure what those page slugs are, go to the “All Pages” screen in your wp-admin and click the “Quick Edit” link for each of those 2 pages. You’ll see a field labeled “Slug”. That’s what you need to change in the code.

    leseg___keikabile

    Again, thank you for your response. The same thing is happening. My front page slug is welcom with with url (‘sitename’) with is the main domain and my home page slug is home… With url “/home”)
    i even tried to use: [ if useer logged in and page template is custom locked down, then redirect to home] i am still geting many redirect massage in the webbrowser.

    leseg___keikabile

    Front Page:[ http://www.royaltweet.com or …/welcome
    Home Page: [ http://www.royaltweet.com/home
    Register Page: …/register
    LoginPage: … /wp-login.php
    ____________________________________________
    The front page has only a welcome text and a trigger hiden logIn no navigations, So when you login it pretty much working and redirect well to profile, but when you type or you go back to the front page you will access it, which is not something i want, because you are already logged in you shouldnt be able to access front page… It wouldnt be nice for user to fall on a page with just lil text and no navigations.

    leseg___keikabile

    I thought may be i could block the page from logged in user and safely redirect to… “/home”
    So i came up with this

    add_action(‘init’, ‘block_page’);
    function block_page(){

    if ( is_user_logged_in() && is_page(‘welcome’) );
    wp_safe_redirect(get_option(‘siteurl’) . “/home”);
    }

    and got too exited then i realised it is falling back. Infect it redirect every url on my site to home except user profile . It worked first time after clearing browser cookies, then back to the same problem again… I cant also access register page and wp-login …

      Patrick Cohen

      This function should work fine. The problem with the code you had originally tried was is_page(‘siteurl’). The presence of siteurl in that line effectively told the browser to redirect every page to home when logged-in. You only want the welcome page to redirect to home when users are logged-in.

      add_action( 'wp', 'custom_loggedin_redirect', 3 );
      function custom_loggedin_redirect(){
      global $wp;
      if (is_user_logged_in() && is_page('welcome'));
      bp_core_redirect(get_option('siteurl') . "/home");
      exit;
      }

    blogmylunch

    @Patrick Cohen
    I really want to do this, but there is also a great landing Homepage template for the theme I’m using. The question is, is there a way to put the Registration and Login and Lost Password forms on it?
    The page has its own template called home or something similar.
    The site is blogmylunch.com

    I want to have something similar to what the Twitter front page used to be, that shows site activity, but then once someone is logged in I want to send them to their page, like on Facebook.

    Nofia

    Campuss Page

    Hi Patrick, i dont know if you have been seeing my messages. i am now using the frisco theme to see if the mobile issue can be solved. luckily it has but not all of it. the problem is finding the ‘page.php’ file which isnt there. i dont know what i can do about it. do you have any clue how i can design a nice landing page just like the one you have discussed here using my frisco theme?

    cesar_oliveira

    Patrick Cohen

    I have the button Login with Facebook.
    When I click enter, it returns the same page.

    I use Buddypres, here’s what I used in my bp-custom.php

    <?php

    // **** Privacy ********
    function restrict_access(){
    global $bp, $bp_unfiltered_uri;

    // If user is not logged in and
    if (!is_user_logged_in() &&
    (
    // The current page is not register or activation
    !bp_is_register_page() &&
    !bp_is_activation_page()

    )

    ) {
    // Redirect to registration page. Change /join to your register page slug
    bp_core_redirect( get_option('home') . '/wp-login.php' );
    }
    }

    add_action( 'wp', 'restrict_access', 3 );

    My website http://www.somdefabrica.com.br Thanks :) Waiting from Brazil \o/

    bestcarsauto

    The snippets”register_nav_menu” you have us search for don’t exist in my functions.php file. All I see that is similar is:

    if ( function_exists( ‘register_nav_menus’ ) ) {
    // This theme uses wp_nav_menu() in two location.
    register_nav_menus( array(
    ‘logged-in-nav’ => __( ‘Logged in Navigation’,TEMPLATE_DOMAIN ),
    ‘not-logged-in-nav’ => __( ‘Not Logged in Navigation’,TEMPLATE_DOMAIN )
    ) );

    Can you please help?
    Thanks

    RE-RE

    Hi Patrick, I currently use the graphene theme. I tried your code above, however, I’m stuck on the first step. I did exactly like you said by copying/pasting the listed code above BEFORE my themes page.php code. It worked just the opposite by blocking content from logged in users and showing for logged out users. This happened before and after your ‘quick edit step for all pages’. BTW, the following comments were found inside my themes code:
    “Run the loop to output the pages. If you want to overload this in a child theme then include a file called loop-page.php and that will be used instead.”
    Any suggestions on how to fix this problem? Thanx in advance.

      Patrick

      The function is on line 84. The instructions at the top of functions.php in the default theme tell you what you need to do: override the bp_dtheme_setup() function in your child-theme, like so:

      function bp_dtheme_setup() {
      register_nav_menus( array(
      'primary' => __( 'Primary Navigation', 'buddypress' ),
      'secondary' => __( 'Secondary Navigation', 'buddypress' ),
      ) );
      }

    PJBursnall

    Hi Patrick,

    I’m using WordPress for a particular project over my preferred CMS, I’m finding your post a great help. It would seem to me that some of what’s done here should be native to WordPress but that’s a different point.

    I’m struggling with step 3 here and the register_nav_menu code required from the functions.php file – I’ve looked at 5 themes, including TwentyTwelve and TwentyEleven, and I can’t see the function you reference in any of them. I’m sure I’m missing something but I have downloaded a number of free templates to check, and…I’m still not seeing it (or finding it with a search).

    Can you help?

    Thanks,
    Paul.

    BionicSquid

    Patrick, this is just a superb piece of tutorial. Thank you so much. I’ve been looking, as I know many have, for a way to lockdown BuddyPress and have found discarded plugins and other detritus which have all been unhelpful. This tutorial, and the tweaks available in the comments, did the trick. I’m also using WPMembers and was able to modify and combine some of the behaviors of this tutorial and that plugin to good effect.

    tom_addis

    Hi Patrick,

    Firstly I’d like to thank you for a brilliant post. You’ve done this for free and it’s helped a lot of people with their jobs and projects. Great work!

    I’ve used this tutorial to build a landing page for a new version of a social hub we’ve been running for about a year now (which is why it’s not on the URL you’d expect).

    The only big problem I have is that since building the landing page the system no longer sends out sign-up confirmation emails or lost password emails.

    I know you’re a busy man but in case I’m overlooking something obvious I thought I’d ask if you have any thoughts.

    Here’s our test site:
    http://www.applausegallery.com/

    Thanks for your help,

    Tom Addis

    bookee

    Hi Patrick,

    I was directed here by Mercime on BuddyPress. She’s great! First of all, thanks for an awesome post. It’s so clear that I get it. Again, thank you!

    I have one quick question though. I’m using BP 1.7 beta 1 and I can’t seem to find the Buddypress “registration” folder from my parent theme. Can you clarify, please?

    jddeisel

    Hi Patrick,
    I am having some issues. So am I right to assume that template-custom-lockdown.php, should just be

    /*
    A lot of code in here
    */

    Also I am using buddypress 1.7 and using buddypress default in the register.php. I have searched and there is no wp_lostpassword_url. I found the form part. The home page has no changed at all for me. Also the bp-default-child shoule going wp-content/themes folder from what I read bp-default can stay in the bp-themes folder is that correct? thanks

    Patrick

    @nobbyrn @michael_vlahov

    Guys, the instructions for the Frisco theme can be found in the functions.php file, right at the top.

    You simply need to create a functions-custom.php file, and copy/paste the bp_dtheme_setup function (from lines 37 to 82 inclusively).

    In functions-custom.php, change line 52 to this:

    // This theme uses wp_nav_menu() in two locations.
    register_nav_menus( array(
    'primary' => __( 'Primary Navigation', 'buddypress' ),
    'secondary' => __( 'Secondary Navigation', 'buddypress' ),
    ) );

    Then save and upload that file to the theme folder. Finally, activate the custom functions file by checking the box in the theme options.

    The modified function in your functions-custom.php file should override the same function in the theme’s default functions.php.

    jayp86

    I tried this and I love it. But I’m having some issues with it. 1: My blog page gets locked whether I have the template set or not set. 2: In i.e and firefox, after a user logs in the page redirects to the same log in page as if the user never logged in, however the user is logged in. The user the have to click on another page to see the logged in menu. This does not happen with Chrome. I’m using the Sahifa theme, I’m not sure if that may have something to do with the issues.

        Chris

        Hey Patrick, thanks.

        I couldn’t figure out where the various bits were in my theme and it appears others here have the same char he so I would like to share my solution.

        2 plugins.

        In the WordPress plugin directory; menu item visibility control. This works kind of like widget logic in that you have an additional field in each of your menu items that accepts a conditional such as ! is_user_logged_in() and is_home etc.

        So you can use this to control the display of menu items depending on if the the user is logged in or not.

        In github and coming to the wordpress plug in directory soon… Private community for bp see bphelpblog.wordpress.com for info

        This plugin lets you select which pages will be visible to public and which page to redirect to if public tries to access user url’s.

        Works great together!

    Fernando

    Hey Patrick, great post!!

    I am noob, so It took me like 4 hours to solve it but I got it!! Actually only one thing is missing..

    Something is wrong with my header.php code, I cant make my logged-out tab appear, it is the same tab logged in or out. This is the code i found in header.php. It is a bit different from the one you requested to search for.

    I am using buddypress 1.7.2, default theme.

    false ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘primary’, ‘fallback_cb’ => ‘bp_dtheme_main_nav’ ) ); ?>

    thank you very much.

    Fernando

    Hey, Patrick! Awesome post.

    It is almost working 100% for me. What I cant get is the header.php file. I cant display my logged out menu and my logged in menu. It is the same in both cases, but when logged-out I cant acess the tabs.

    My header.php file is a bit different than your, could you give me a hand to finish it?

    This is what i could find in the Header file:

    false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘primary’, ‘fallback_cb’ => ‘bp_dtheme_main_nav’ ) ); ?>

    Thak you very much!

    craigweb

    Congrats on an epic post, I’ve just followed this and I was looking everywhere for a solution so thanks for taking the time to write it.

    I’m also wondering if it’s worth elaborating in the following way, as now I’m searching for a solution to the following.

    I wanted the logged out users to access to a homepage registered at http://www.mydomain.com, instead of being redirected to http://www.mydomain.com/welcome. This allows me an extra page of information, and allows me to use my welcome page for more detailed sign up information.

    However this causes an obvious problem in that logged in users, when clicking home or the logo, head to the homepage with the logged out template we created, but with their logged in menu (for obvious reasons ;).

    I would like logged in users to be forwarded to their own homepage when clicking home / the logo.

    What function / action etc would I need to add to accomplish this?

    Prince

    Sir i want to know that which theme you have used in this tutorial..
    Because in many themes i have tried .

    Every time i face error like “Your theme does not natively support menus, but you can use them in sidebars by adding a “Custom Menus” widget on the Widgets screen.”
    So please sir help me to fix it..
    Please provide me your theme link on [email protected]

    Prince

    Hello Patrick.

    I did all things even though i am not able to add menus i tried my best to do it.
    watched videos in youtube how to do but failed in adding menus please can you help me to add menus in it.
    can you tell me the steps how to do it in Iconic one

    Thanks in Advance.

    Prince

    Hello Patrick i did everything but i don’t know where i did mistake that
    Activity Streams Directory Page is opning although My landing page tab is there. And 2nd thing my site introduction and image is also not coming in my landing page.
    . And Patrick can you help me managing my sign up form into 3 blocks and then 2 blocks its coming in an unordered way.

    Please try to help me as soon as possible..

    Prince

    Hello Patrick i did everything but i don’t know where i did mistake that
    Activity Streams Directory Page is opening directly although My landing page tab is there. And 2nd thing my site introduction and image is also not coming in my landing page.
    . And Patrick can you help me managing my sign up form into 3 blocks in left and then 2 blocks in right its coming in an unordered way.

    Please try to help me as soon as possible..

    Patrick

    Hi there @Prince

    Well, I see you have made excellent progress. And you are using a child-theme. Congratulations!

    The landing page issue –
    It looks like you may have selected the Activity page under Settings > Reading at “Front page displays”. Please try changing that to the 1st option – “Your latest posts”.

    The landing page introduction and image –
    I see you are using the Twenty-Ten theme. Be sure you have used this…
    get_template_part( ‘loop’, ‘page’ );
    …in div id=”my-custom-home” in Step 2 above instead of this…
    get_template_part( ‘content’, ‘page’ );

    The signup form layout –
    Add the following to your child-theme style-sheet to snap it right into shape:

    #register-page #basic-details-section, #register-page #profile-details-section {
    float:left;
    width:48%;
    }
    #register-page #basic-details-section label, #register-page #profile-details-section label, #register-page #basic-details-section input, #register-page #profile-details-section input, #register-page #profile-details-section p {
    float:left;
    width:90%;
    }

    Prince

    Thank you Patrick for your help my registration form is in order now.
    But i didn’t understand that you told about The landing page introduction and image.
    can you explain me this briefly.

    And 2nd thing whenever user logout i want that he should log out again to my landing page is it possible.

    Patrick

    Hi again @Prince

    This is starting to look like a support forum, lol :)

    The Twenty-Ten theme does not use the same code as shown in Step 2.

    So instead of this:

    < ?php the_post(); ?>
    < ?php get_template_part( 'content', 'page' );?>

    You should add this to your landing page template:

    < ?php the_post(); ?>
    < ?php get_template_part( ‘loop’, ‘page’ );?>

    As for logging out, users should be redirected automatically to your landing page.

    Kevin

    I’ve been able to get most of this setup with one major problem. When trying to login from the landing page, rather than successfully logging in, the landing page reloads each time you hit the log in button. The user isn’t logged in and no error message is displayed.

    I’m thinking that there might be some issue where the follow on page that needs to load after logging in is being blocked by the custom template. Any idea why this might be happening?

    Ashley

    Thank you so much for your post – I’m very much a beginner and was able to figure this out. I’m down to the final step and hoping my question is an easy one.

    I’m using a frisco child theme and was one that had to use:

    in my register.php because there aren’t template parts.

    For some reason the CSS will not float this left…grrr.
    Here is the URL: http://itefboardportal.com/welcome/

    I’ve tried using the code inspector on my browser and just can’t seem to crack it.

    Any suggestions?

      Patrick

      Hey there @Ashley

      Yep, to get floats to play nice, defining container widths helps. Adding width:68%; to #my-custom-home should do the trick.

      Also, you may want to reduce the width of #my-custom-registration to 95% in your theme, as the margin is adding to the overall width.

      Plus, as you have added margin:2em; to #my-custom-registration, you may want to remove the margin from the h2 heading to reduce that huge white-space above it. :)

      Finally, remember that your theme is responsive, so you’re gonna want to tweak at least some widths (maybe padding & margins too) for smaller screen sizes. Try adding this media query to your style-sheet for starters and adjust if required:

      @media only screen and (max-width: 767px) {
      #my-custom-home, #my-custom-registration {width:auto;}
      #my-custom-login {width:90%;}
      }

      I hope this helps!

    tim_merithew

    So when i went on my themes editor to look for a registration.php, I could not find one. The only thing I could find was just a buddypress.php and when I searched the actual plug-in, i couldn’t find one there either. I am using the Avada theme from ThemeFusion. Could it be because of my theme?
    I would really like to be able to do this and I can’t find any other support on the web!

    Chris

    Tim,
    It might be easier for you to simply use some plugins.

    1-) Private Community For BP Lite, Makes BP pages private and only accessable to logged in users with the exception of the pages you set.

    http://wordpress.org/plugins/private-community-for-bp-lite/

    This will let you control which pages are visible to non-logged in users.

    2-) Menu Item Visibility Control, Control individual menu items’ visibility based on your desired condition.

    http://wordpress.org/plugins/menu-items-visibility-control/

    This will let you control which menu items are visible to users that are logged in, or not. It uses conditional logic, so if you are familiar with “widget logic” plug-in, this will be intuitive to you. If not, then it is easy enough to learn.

    I use these two plugins together to show specific pages and specific menus to non-logged in users that promote my site and encourage them to join. Once logged in then of course they can see all pages and menu items.

    Hope this helps.

    Cheers!
    Chris

    tim_merithew

    That is great advice, thank you! What would be the best way for me to go about making a landing page than with the registration form / log-in on it?
    I am not as concerned about blocking access to non-logged in users, but more about creating a landing page which they can sign up on / log-in without having to click around!

    Thank you!

    Patrick

    Hi there @tim_merithew

    Since BuddyPress 1.7, themes no longer need special templates included to be compatible. So it’s quite possible that your current theme doesn’t have it.

    If your theme does not have a registration folder with the register.php template in it, you can simply copy the folder from the default theme in your copy of BuddyPress.

    Browse to buddypress/bp-themes/bp-default/ and copy the registration folder from there into your theme (or child-theme if you’re using one).

    Once you have the register.php template open, be sure to inspect the HTML structure of templates from your theme, and that that structure is mirrored in register.php so the base layout of register.php will be just like any other page on your site.

    roose_sigmond

    @Patrick

    Oh man, I like the way you explain in detail. Concise and clear.

    Now, may I ask, can I just follow #2 for my landing page Only? Or can you spare a much clearer for Landing page only same as your Demo. I am using Mesocolumn Theme.

    I tried it but seems not working for me maybe because its connected with the rest of your instruction.

    Oksana

    Hi! Thank you so much for wonderful explanation. Everything went well till the point I had to create custom Log out menu.
    I could not find nothing similar to this in factions file:

    if ( ! function_exists( ‘theme_register_menus’ ) ) :
    function theme_register_menus() {
    register_nav_menu(‘top_menu’, __(‘Top Menu’, TEMPLATE_DOMAIN));
    }
    endif;

    I am using buddyboss theme.
    Thanks in advance for your help!

    CAROLINA

    Hi
    I’ve tried this code many times, with many different themes, and it never works.
    What do you mean with:
    Note that the code above applies to more recent themes that use template parts. If your theme does not use template parts, see the comments below for an easy solution.

    I’m using now MesoColumn theme, a basic WordPress theme for BuddyPress, and it just wont work, it doesn’t hide the sidebar, or replace the menu…
    this is my test url I really hope you can give me some guidance: http://www.thinkerthing.com/OBGWP

    Thanks!

    Marchael

    Hello, first of all I want to thank you for sharing this knowledge and tutorial. I follow your instruction but now i’m a little confused in this statement that you post:
    “As we want our landing page to have a similar layout as pages using the custom template we made earlier, remove the following Buddypress code from your child-theme’s register.php file. Remember to remove the corresponding closing div tags near the end of the file too, or things will go haywire!”

    what would be the exact buddypress code that I need to remove? I know that I need to remove also those div tags but I didn’t know the exact buddypress code that I need to remove. please help me. sorry for a noob question. thanks

    Tim

    Thank you for a great topic, however I am having an issue. My site http://www.tailsandtoms.com has a few pages that the public can view, but I hid the members, activities page etc and have a hidden forum. I did keep the sidebar visible. I do manual registration so some of the functions you mentioned I did not need (registration etc).
    Here is my problem, when I go to my domain it brings up the front page of my website (good) but now following your method I ended up with an additional home page ( /home as mentioned in the redirect). The problem is I have been updating the front page (what shows up when you just go to the domain), and I have to go and edit the /home page to match it.
    Is their a way to do this and send the unlogged in users to my normal domain front page instead of a separate /home page.
    Sorry if that is confusing, all this stuff is new to me.

      Marchael

      hello @Tim
      You said that you have an additional homepage? It is not clear to me but if you want your register and login page as your homepage, first you need to integrate login to registration as one page. Then go to dashboard -> settings, under the settings click the reading and set your front page as a static page and choose a page you want to display as a front page

Comments are closed.