BuddyDev

Search

[Resolved] Default Home Tab for Groups

  • Participant
    Level: Enlightened
    Posts: 42
    Propertytips on #20958

    Hi Brajesh,

    I created a home page tab for each of my “Private groups” with the “BuddyPress Group Tabs Creator Pro” Plugin.

    The home page tabs works well for the Public Groups…

    The problem is that the home page of each of the “private groups” is not visible to non members of the group as the page displays the notice

    “This is a private group and you must request group membership in order to join.”

    I need each of the private groups “home page tab” to be visible to NON members of the group as the home page helps sell the benefits of the private group thus encouraging more people to request membership of the group.

    Is there a way I can get the home page tab of the private groups to display for all users of the site whether they are members of the group or not?

    Kind Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24332
    Brajesh Singh on #20960

    Hi Propertytips
    I am sorry but the plugin can not help with it.

    This is due to the way BuddyPress template packs and most themes are coded. A content template is not loaded if the group is not visible and only group status is shown.

    If you want to achieve it, you will need to modify buddypress/groups/single/home.php in your theme(you can copy it to your child theme from current active theme or template pack).
    I will not recommend it unless you know php and can only exclude for certain pages.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 42
    Propertytips on #20962

    Thanks for the response, Brajesh.

    What about if I made the groups “public” and use the method suggested by imath using the “Alternative Public Group Control plugin”?

    I seem to be able to get the home page to display for all “Public groups” using this method and members have to request to join the group before they can see all the other tabs

    The only problem I have is how to protect my “group blog”. Although the blog tab is removed in the buddypress area… the contents of the group blog are still accessible .

    I have a blog for each of the groups using the “blog categories for group plugin” which I have achieved by using the setting “Link to normal site blog post page”

    Is there a way that I can still protect the blog content… so that if you are not a member of a particular group… you cannot read the full content of the article.

    …so if you are in group A … you cannot read group B blog except you join

    I hope I am clear with my explanation of what I am trying to achieve

    Kind Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24332
    Brajesh Singh on #20974

    Hi Propertytips,
    Is the blog post only visible in group page or is it part of your main site too? If it is part of the group page only, It can be easily achieved.

    Please let me know and I will help.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 42
    Propertytips on #20981

    The blog is part of the main site too at the moment… as I list the excerpts of the groups on the sidebar to encourage other members to get a taster of what they can enjoy by signing up for the group

    If the other site users click on the excepts and get a message that they need to sign up with the group to access the post… that will be so cool

    Kind Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24332
    Brajesh Singh on #20990

    Please use the following to restrict and redirect to group home page

    
    
    /**
     * Restrict single group posts on the main blog.
     */
    function buddydev_bcg_single_post_protect() {
    	if ( ! is_singular() ) {
    		return;
    	}
    	$post_id  = get_queried_object_id();
    	$group_id = get_post_meta( $post_id, '_bcg_group_id', true );
    	if ( ! $group_id ) {
    		return;// not a group post.
    	}
    
    	$group = groups_get_group( $group_id );
    	if ( ! $group->id ) {
    		return;// the group was perhaps deleted.
    	}
    
    	if ( ! is_user_logged_in() || ! groups_is_user_member( get_current_user_id(), $group_id ) ) {
    		bp_core_redirect( bp_get_group_permalink( $group ) );
    	}
    }
    
    add_action( 'bp_template_redirect', 'buddydev_bcg_single_post_protect' );
    
    

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 42
    Propertytips on #20993

    Thank you so much Brajesh, …. This works absolutely so well for me… just what I wanted for the protection of my blogs.

    I believe this snippet will be very useful for other people using the “categories for group blog” plugin. (deserves to be in code snippets section)

    I can now have home pages for my groups

    I create the groups as public groups but Members still have to request permission (using the “Alternative Public Group Control plugin”)

    Your snippet ensures that non members cannot read the blog even if they see the excerpts of the group anywhere on the site

    Voila… the group post are protected!!

    The only thing left for me to do is get the blog items that were created before the groups protected.

    Can you please tell me if there is a way to identify group post that were created from the “front end” and the ones that were created from the “admin panel” in the PhpMyAdmin panel…

    and if there is anything I can add in the phpmyadmin panel to convert each post created in the admin panel so that they behave as if it was created from the group blog.

    This will help convert some of my old blogs into full group blogs…. making them protected too

    I don’t mind going through each post in the phpmyadmin to add a couple of lines

    Kind Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24332
    Brajesh Singh on #21001

    Hi Propertytips,

    Thank you.

    We store two meta keys for each post

    1. _bcg_group_id where we store the associated group id.
    2. _is_bcg_post it is used for backward compatibility. Even though we can do without it, It is there for backward compatibility. We were not storing group ids earlier.

    These 2 meta should be present for the posts.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 42
    Propertytips on #21019

    Thank you so much, Brajesh.

    So if i go into the custom field of each post and enter the following

    under name I enter

    _bcg_group_id

    and under value,

    _bcg_group_id (the id number of the group for the post)

    followed by

    entering under name

    _is_bcg_post

    and then under value, I enter 1

    Will that sort my problem out?

    Kind Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24332
    Brajesh Singh on #21022

    Hi Propertytips,
    Thank you.

    Yes, That is correct.

    Best regards
    Brajesh

The topic ‘ [Resolved] Default Home Tab for Groups’ is closed to new replies.

This topic is: resolved