BuddyDev

Search

[Resolved] Separating BuddyBlog posts from Main Blog

Tagged: 

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #61

    Hello BuddyDev folk!

    Thank you for your wonderful plugins. 🙂
    I wrote a Contact message here last week or so, but never got a reply — and I just realized it might have got lost during the whole transition to new discussion forums, so I’ll repeat what I can here.

    Basically I got the BuddyBlog plugin, which is great!
    However, I was hoping there was a way for BuddyPress users to ONLY post their own blog posts within their BuddyPress profile pages, and that it would NOT also post on the main blog page of the site (which I want reserved only for me). Is that possible? It may be, and I’m just not understanding how it works.

    Your article here, in the “Bonus 2” tip, makes it sound like it’s a way to do what I’m asking:
    https://buddydev.com/buddypress/introducing-buddyblog-allow-users-to-blog-from-their-buddypress-profile/
    …however I added the code “add_filter(‘buddyblog_show_posts_on_profile’,’__return_true’);” to my functions.php file in my child theme, and nothing seems to be any different. (The user-created posts still appear on my site’s main blog). Or was this bonus tip meant for something else entirely?

    I also wasn’t sure if custom post types was another way of doing what I need or not. Please advise!

    One last thing — the user-created posts have URL’s that look like this:
    http://www.mydomain.com/members/username/buddyblog/my-posts/XXXX/”
    Is there a way to change the “buddyblog” part in that URL to something else? (Like “my-blog”?)

    Thanks in advance for any help you can give!

  • Keymaster
    (BuddyDev Team)
    Posts: 24697
    Brajesh Singh on #62

    Hi Rojo,
    Welcome to the BuddyDev Forums.

    I am sorry that we could not get back to you over mail. Things have been a little bit hectic here as we are trying to improve the support experience.

    Now getting back to the topic, which version of BuddyBlog you are using? Is it version 1.1 or above? If yes, most of the things you want can be configured from Admin settings.

    Please visit Dashboard->settings and click on the ‘BuddyBlog’ menu. You will see the settings option there.

    1. Please check the settings for ‘Show single posts on user profile?’ make sure it is set to yes. That will make the posts to be linked on profile. They will be still visible on the blog archive post(on main site, I will get back on excluding in a minute.

    2. To exclude the posts from the main blog:- There are multiple ways to achieve it. I am not sure which will suit you the best, so I will list both the approach.

    2a) If possible, you can create a custom post type and select that as the BuddyBlog post type from the settings page. This will make sure that the custom post type is never visible on your main blog.

    2b) Second approach is to limit posts to 1 category and exclude that category from main blog.

    It will need some code

    
    add_action( 'bsfep_post_saved', 'buddydev_add_default_category_to_post' );
    function buddydev_add_default_category_to_post( $post_id ) {
    	
    	$post = get_post( $post_id );
    	
    	
    	if( ! $post )
    		return ;
    	if( $post->post_status == 'publish' ) {
    	
    		$term = 'alpha-beta';//change this to your category slug
    
    		wp_set_object_terms( $post->ID, $term, 'category');
    	}
    }
    
    

    Please change ‘alpha-beta’ to your category slug in the above. Make sure you have Enable taxonomy disabled in the settings. Now when the user will post, It will be assigned the given category.

    Excluding category

    
    function buddyblog_custom_exclude_category( $query ) {
    	//don't modify in admin list or on BuddyPress pages
    	if( is_admin() || is_buddypress() )
    		return ;
    	
        if ($query->is_main_query() ) {
            $query->set( 'cat', '-32' );//IMPORTANT: change 32 to your category id. Please make sure to keep the minus(-)
        }
    	
    }
    add_action( 'pre_get_posts', 'buddyblog_custom_exclude_category' );
    

    Make sure to change 32 to the user category id.

    I will prefer the first approach though as that is very straightforward

    3. Change slug ‘buddyblog’ from url

    
    define( 'BP_BUDDYBLOG_SLUG', 'some-slug-that-you-want');
    
    

    Put that code in the bp-custom.php( link: https://buddydev.com/docs/guides/guides/buddypress-guides/what-is-bp-custom-php/) and that should do it.

    Let me know if you need further assistance.

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24697
    Brajesh Singh on #63
  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #64

    Brajesh – Thanks so much for your helpful reply!!

    It sounds like the first approach is probably best, so I will attempt that. I can still follow the instructions from that first blog post, yes? (Or has it changed?)

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #65

    P.S. – Would using something like this plugin work for creating the Custom Post Type needed for BuddyBlog?:
    https://premium.wpmudev.org/project/custompress/

    Or do I need to only do it by the method you demonstrated?

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #66

    Nevermind!

    I tested things out using CustomPress for BuddyBlog, and it seems to work just fine!
    I chose the newly-created custom post in BuddyBlog’s settings, and now that only appears in the personal profile pages, and NOT in the main blog.
    So great! Your plugin is AMAZING!!!! 🙂
    Thank you again.

    A couple of minor things I noticed….
    When I publish a post, a message that my post has been successfully published appears. (I think this message usually sticks around, but with the particular theme I’m using this message disappears after a few seconds). But the form (with what I filled out within) still stays around, and so it can seem like maybe the post did NOT actually publish, even though it did. (Especially with my theme making that “success” message disappear). And so I can see a lot of people accidentally clicking publish over and over again, if they’re not sure (causing repeats).

    Any chance, in a future update, that you can make it so it goes to the list of published posts after hitting publish? (Just to avoid any potential confusion).

    Also, I noticed some typos that that I wanted to point out. I named my custom post type “Blog Posts,” and so the message that appears when I publish is: “Blog Post Saved as publish successfully.” That should probably be “Blog Post saved and published successfully” instead.

    In addition, when you click on an individual post, the date says “postend on 8/3/2015” instead of “posted on 8/3/2015” (there’s an extra “n” there).

    Besides these minor things, everything is working beautifully, and it’s an incredible plugin!!

  • Keymaster
    (BuddyDev Team)
    Posts: 24697
    Brajesh Singh on #67

    Hi Rojo,
    Thank you.
    I am glad that you figured out most 🙂

    For the typo and the redirect, I will update the plugin again today and post back then.

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #68

    Wow, that’s incredible. THANKS!!

    I look forward to it.

  • Keymaster
    (BuddyDev Team)
    Posts: 24697
    Brajesh Singh on #69

    Hi Rojo,
    Thank you.

    I have updated both the plugins now. It fixes the typo and allows you to control where to redirect from the BuddyBlog settings.

    Please make sure o upgrade to BuddyBlog 1.1.3 and Simmple Front End Post 1.2.1.
    The redirect feature needs BP Simple Front End Post 1.2.1

    If you are looking for easy upgrade, you might want to install BuddyDev Dashboard, that allows automatic upgrade for our plugins.

    https://buddydev.com/support/forums/topic/now-you-can-get-automatic-upgrades-for-all-buddydev-plugins/

    Please do check and let me know if it works for you or not?

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #70

    Fantastic!!

    Looking forward to downloading the new versions, as well as the BuddyDev Dashboard (cool feature!!)

    THANKS AGAIN!

The topic ‘ [Resolved] Separating BuddyBlog posts from Main Blog’ is closed to new replies.

This topic is: resolved