BuddyDev

Search

[Resolved] Need to Limit Categories Users Can Post To in BuddyBlog

Tagged: 


  • Participant
    Level: Initiated
    Posts: 12
    Devin Stone on #135

    Hey Brajesh Singh,

    First off, amazing plugin! I have tried many plugins for my BuddyPress website, and this is by far the most useful for what I’m trying to achieve. I appreciate the hard work and decided to buy a premium support membership to show it. It seems the premium support is down at the moment though, but hopefully this place will work just as well.

    My install is such:

    – No multi-site
    – Using BuddyPress 2.3.2.1
    – Not sure how specific this installation would be considered, but it’s not multi-network or multi-blog to my knowledge. Though I’m not an expert. I do have a few custom modifications however.
    – WordPress 4.2.4
    – Sweetdate child theme (http://themeforest.net/item/sweet-date-more-than-a-wordpress-dating-theme/4994573)
    – Fresh install (running on a local DesktopServer environment currently)
    – I’m currently running my website draft offline via DesktopServer
    – I’ve posted Sysinfo at the bottom of this post to keep it cleaner.

    My setup:

    I am running a social network through BuddyPress. I have two blog pages in the main navigation menu, “Official Blog” and “User Blogs”. The Official Blog contains all post categories minus Uncategorized and the User Blogs category/sub-categories. The User Blog page contains all the User Blog category/sub-categories minus Uncategorized and the Official Blog categories/sub-categories. The user’s individual blogs are also viewable from the user’s BuddyPress profile. Users can only post through their BuddyPress profile page.

    My current Categories look like this:

    – Guest Writers
    – Pick Up
    – Dating & Relationships
    – Fashion & Style
    – Online Game
    – Phone & Text Game
    – Sex
    – Self-Improvement
    – Health
    – Money
    – Spirituality
    – Uncategorized
    – User Blogs
    – Pick-Up
    – Dating & Relationships
    – Fashion & Style
    – Field Reports
    – Online Game
    – Phone & Text Game
    – Sex
    – Self-Improvement
    – Health
    – Money
    – Spirituality
    – Wingman Locator™ News

    What I Need:

    I need for all User blog posts to be automatically assigned to the parent category User Blogs, and not have it appear as an option on the blog post screen. I then want them to be able to select ONE category from sub-categories:

    – Pick-Up
    – Dating & Relationships
    – Fashion & Style
    – Field Reports
    – Online Game
    – Phone & Text Game
    – Sex
    – Self-Improvement
    – Health
    – Money
    – Spirituality

    So the blog post category would end up looking like “User Blogs, X” on the post page. I also need to restrict their access to posting to the Uncategorized and Official Blog categories (and their sub-categories), and don’t want them to even appear on the category list as options when creating a post.

    I viewed your response to Sam here (https://buddydev.com/buddypress/buddyblog-update-and-bug-fixes/). It got me started with just the automatic posting to the User Blog category, but as you can see I need a little bit more. I have since removed the code provided and am back to the default settings.

    I also love the drop down list format you gave to Rafael here (https://buddydev.com/buddypress/introducing-buddyblog-allow-users-to-blog-from-their-buddypress-profile/). The code overwrote the settings to Sam’s code, and I need to do a bit of CSS work to make it perfect, but ideally I’d like to see my above situation solved in the form of a drop down box.

    Thank you very much for your help! A+ plugin!

    ———

    WordPress Version: 4.2.4
    PHP Version: 5.4.19
    MySQL Version: 5.1.44
    Web Server: Apache/2.4.4 (Unix) PHP/5.4.19 OpenSSL/1.0.1e mod_perl/2.0.8-dev Perl/v5.16.3

    WordPress URL: http://www.wingmanlocator.dev
    Home URL: http://www.wingmanlocator.dev

    Content Directory: /Users/MMaS/Sites/www.wingmanlocator.dev/wp-content
    Content URL: http://www.wingmanlocator.dev/wp-content
    Plugins Directory: /Users/MMaS/Sites/www.wingmanlocator.dev/wp-content/plugins
    Plugins URL: http://www.wingmanlocator.dev/wp-content/plugins
    Uploads Directory: /Users/MMaS/Sites/www.wingmanlocator.dev/wp-content/uploads

    Cookie Domain: Disabled
    Multi-Site Active: No

    PHP cURL Support: Yes
    PHP GD Support: Yes
    PHP Memory Limit: 256M
    PHP Memory Usage: 77.71M (30%)
    PHP Post Max Size: 128M
    PHP Upload Max Size: 128M

    WP Options Count: 791
    WP Options Size: 208.15kb
    WP Options Transients: 22

    WP_DEBUG: Disabled
    SCRIPT_DEBUG: Disabled
    SAVEQUERIES: Not set
    AUTOSAVE_INTERVAL: 60
    WP_POST_REVISIONS: 1

    Operating System: Mac
    Browser: Google Chrome 44.0.2403.155
    User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36

    Active Theme:
    – Sweetdate Child

    Active Plugins:
    – bbPress 2.5.7
    http://bbpress.org

    – BP-WP Profile Reviews 1.6
    http://spoonjab.com/bp-wp-profile-reviews/

    – bpchat 1.0.8
    http://bpchat.wpapplab.com/

    – BP Show Friends 2.0
    http://imathi.eu/tag/bp-show-friends/

    – BP Simple Front End Post 1.2.1
    https://buddydev.com/plugins/bp-simple-front-end-post/

    – BuddyBlog 1.1.3
    https://buddydev.com/plugins/buddyblog/

    – BuddyPress 2.3.2.1
    https://buddypress.org/

    – BuddyPress Automatic Friends 2.0.5
    http://www.stevenword.com/bp-automatic-friends/

    – Buddypress Upload Avatar Ajax 1.0.1
    http://tutviet.net

    – BuddyPress Usernames Only 0.6
    http://wordpress.org/extend/plugins/buddypress-usernames-only

    – BuddyPress Wall 0.9.4

    – Contact Form 7 4.2.1
    http://contactform7.com/

    – Dynamic Widgets 1.5.10
    http://dynamic-widgets.com/

    – Enable Media Replace 3.0.3
    http://www.mansjonasson.se/enable-media-replace

    – Events Manager 5.5.7.1
    http://wp-events-plugin.com

    – Fancier Author Box 1.4
    https://wordpress.org/plugins/fancier-author-box/

    – GEO my WP 2.6.0.2
    http://www.geomywp.com

    – GMW Add-on – Xprofile Fields 1.3.1
    http://www.geomywp.com

    – Google CSE 1.0.7
    http://wordpress.org/extend/plugins/google-cse/

    – Hide Admin Bar From Non-admins 1.0
    http://www.paidmembershipspro.com/wp/hide-admin-bar-from-non-admins/

    – Meks Smart Author Widget 1.0.6
    http://mekshq.com

    – Page Builder by SiteOrigin 2.1.4
    https://siteorigin.com/page-builder/

    – Paid Memberships Pro 1.8.4.2
    http://www.paidmembershipspro.com

    – Paid Memberships Pro – Email Templates Add On .5.4.2
    http://www.paidmembershipspro.com/add-ons/plugins-wordpress-repository/email-templates-admin-editor/

    – Paid Memberships Pro – MailChimp Add On 1.0.7
    http://www.paidmembershipspro.com/pmpro-mailchimp/

    – Restrict Categories 2.6.3

    – Revolution Slider 4.6.92
    http://www.themepunch.com/revolution/

    – rtMedia for WordPress, BuddyPress and bbPress 3.8.6
    http://rtcamp.com/rtmedia/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media

    – Share Buttons by AddToAny 1.6.3
    https://www.addtoany.com/

    – Simple Ads Manager 2.9.5.118
    http://www.simplelib.com/archives/wordpress-plugin-simple-ads-manager/

    – SysInfo 1.1.0
    http://wordpress.org/extend/plugins/sysinfo/

    – Theme My Login 6.3.12
    http://www.jfarthing.com/extend/wordpress-plugins/theme-my-login/

    – WooCommerce 2.3.11
    http://www.woothemes.com/woocommerce/

    – WordPress Importer 0.6.1
    http://wordpress.org/extend/plugins/wordpress-importer/

    – WordPress Popular Posts 3.2.3
    http://wordpress.org/extend/plugins/wordpress-popular-posts

    – Yet Another Related Posts Plugin 4.2.5
    http://www.yarpp.com/


  • Participant
    Level: Initiated
    Posts: 12
    Devin Stone on #136

    It seems my category list formatting didn’t take in my original post. I’ve attached a screenshot here instead. http://i.imgur.com/kTVXSw8.png

    If I can throw in another small request, I’d like to know how to remove the bullets from the category list as well. Thanks!


  • Keymaster
    (BuddyDev Team)
    Posts: 13806
    Brajesh Singh on #137

    Hi Devin,
    Welcome to the BuddyDev forum and thank you for Buying the support.

    Your details and very clear and concise. If I understand correctly, all we need to do is allow the users to select from sub category of the User blogs and when the post is saved assign the sub category as well as parent category?

    If that is correct, please give me a couple of hours and I will post the code.

    PS: We are phasing out all other support channels in favor of this support forum.


  • Participant
    Level: Initiated
    Posts: 12
    Devin Stone on #140

    Correct!


  • Participant
    Level: Initiated
    Posts: 12
    Devin Stone on #141

    I realized I made a slight mistake in my original description. I said “I then want them to be able to select ONE category from sub-categories:” followed by “So the blog post category would end up looking like “User Blogs, X” on the post page”. However, I realized that sometimes I need for the blog post categories to show three categories like “User Blogs, X, X”. This is because third level sub-categories, like “Dating & Relationships”, are structured like “User Blogs -> Pick-Up -> Dating & Relationships”.

    To summarize, I need for users to only be able to select one category, but if the chosen category is a third level sub-category, I’d like for it to also display it’s second level parent category. I understand if this is too late to request, but I thought I’d throw it out there if it’s an easy fix. Thanks again!


  • Keymaster
    (BuddyDev Team)
    Posts: 13806
    Brajesh Singh on #142

    Hi Devin,
    I have got the first case working. I had to modify the simple front end post plugin slight to accommodate child_of argument for taxonomy.

    I have a question about your last requirement. Why not we just assign the child selected category only to the post and while listing, we list from that child to the top level.

    A post in any child category of a category will also appear in the archive of the parent category of the selected category, so that is never a problem.


  • Keymaster
    (BuddyDev Team)
    Posts: 13806
    Brajesh Singh on #143

    And to achieve what I said in my last post will be as simple as changing

    
    get_the_category_list( ', ')
    
    

    to

    
    get_the_category_list( ', ','single' )
    

    in our post listing template


  • Participant
    Level: Initiated
    Posts: 12
    Devin Stone on #144

    Glad to hear about the archives!

    I’m not sure what you mean by “assign the child selected category only to the post and while listing, we list from that child to the top level.” Could you explain further?


  • Keymaster
    (BuddyDev Team)
    Posts: 13806
    Brajesh Singh on #145

    Hi Devin,
    1. Please upgrade to simple front end post plugin version 1.2.2

    2. Please put the following code in your bp-custom.php

    
    
    add_filter( 'buddyblog_post_form_settings', 'buddyblog_show_custom_cats', 100 );
    
    function buddyblog_show_custom_cats( $settings ) {
    	$tax = array();
    	 
    	$tax['category'] = array(
    
    		'taxonomy'		=> 'category',
    		'view_type'		=> 'dd',
    		'child_of'		=> 29 //CHAGE It with the correct ID
    	);
    	
    	$settings['tax'] = $tax;
    	
    	return $settings;
    }
    

    Change the vale of child_of with the actual ID of your “User Blog” category.

    That will show the dropdown list on Post Create/edit. will work for any level deep.

    Now, to show the category parents, Please make sure you copy wp-content/plugins/buddyblog/template/buddyblog folder to your theme. So, now you have yourtheme/buddyblog folder where three files are there. These files are used to display the BuddyBlog post etc on user profile.

    Now, check for the file/code that generates link to category. In that file, you will see code like this

    
    get_the_category_list( ', '  )
    

    Please change that to

    
    get_the_category_list( ', ','single' ) )
    

    After that, try posting and see if it works. Please do let me know how it went for you.

    Thank you
    Brajesh


  • Participant
    Level: Initiated
    Posts: 12
    Devin Stone on #156

    Wow, that worked almost perfectly! Thank you so much!!!

    There are only two more minor revisions that I saw need to be done.

    1. If a user does not select a category at all, then the blog post goes into “Uncategorized”, which is a problem because “Uncategorized” is a higher ranked category than “User Blogs”. This means any “Uncategorized” posts will be organized in the Official Blog, not the “User Blogs” and its child categories. I have since created an additional “Uncategorized” child category under “User Blogs”. Is there a way for someone who does not select a category to be automatically assigned to “User Blogs -> Uncategorized”?

    2. Is there a way to order which category is listed first on the drop down list?

The topic ‘ [Resolved] Need to Limit Categories Users Can Post To in BuddyBlog’ is closed to new replies.

This topic is: resolved
Subscribe