Replies
Hi Peter,
After looking at our admin panel, It does not seem a good idea to allow checking the terms and there can be multiple taxonomies allowed and that can lead to a lot of confusion.So, I am posting code snippet to make it work like you want here. You can put these snippets in your bp-custom.php or your theme’s functions.php
Step 1: decide the taxonomy and terms you want to limit users
function buddyblog_custom_get_allowed_taxonomy() { return 'category';//your taxonomy } function buddyblog_custom_get_allowed_term_ids() { return array( 1,2,23 );//your own set of ids for category }
Change the values in these two functions as appropriate. We will use it in our next step.
Step 2: Limiting Users to post to certain terms only
/** * Limit User posts to selected category only * * @param int $settings * @return int */ function buddyblog_selected_cats_only( $settings ) { $taxonomy = buddyblog_custom_get_allowed_taxonomy();//which tax we are limiting too , you must have selected it in the admin settings if ( $settings['tax'][ $taxonomy ] ) { $settings['tax'][ $taxonomy ]['include'] = buddyblog_custom_get_allowed_term_ids() ;//array of term ids in that taxonomy } return $settings; } add_filter( 'buddyblog_post_form_settings', 'buddyblog_selected_cats_only' );
That’s all, you don’t need to make any change in the second block as it uses the values from first block.
Step 3: Do it only if you want to limit certain posts to be linked on profile and not others
function buddyblog_filter_posts_permalink_preference( $pref, $post ) { $terms = get_the_terms( $post, buddyblog_custom_get_allowed_taxonomy() ); if ( empty( $terms ) ) { //what to do when there are no cats attached //you decide return $pref; } $selected_term_ids = buddyblog_custom_get_allowed_term_ids(); $term_ids = wp_list_pluck( $terms, 'term_id' ); $has_selected_terms = array_diff( $term_ids, $selected_term_ids ); //all or atleast one term found if ( empty( $has_selected_terms ) || count( $has_selected_terms ) != count( $term_ids ) ) { $pref = true; //yes show it on profile } else { $pref = false; //dont show it on profile } return $pref; //return false if you don't want post to be linked to profile } add_filter( 'buddyblog_show_posts_on_profile', 'buddyblog_filter_posts_permalink_preference', 10, 2 );
In the above example, we are doing it based on the selected category. I don’t think it is a good strategy as we we are looking for the post terms before deciding permalink. There is a better solution using custom meta. We store a meta field( “_is_buddyblog_post”) whenever a post is posted/edited from front end(It was added in 1.1 and due to back compatibility I can not use in the plugin itself).
The simple way to filter permalink should to be to check if this meta exists and if yes, link to profile else link to normal like below
function buddyblog_filter_posts_permalink_preference2( $pref, $post ) { if( get_post_meta( $post->ID, '_is_buddyblog_post', true ) ) { //this was posted via buddyblog $pref = true; } else { $pref = false; } return $pref; //return false if you don't want post to be linked to profile } add_filter( 'buddyblog_show_posts_on_profile', 'buddyblog_filter_posts_permalink_preference2', 10, 2 );
You can play with the filter ‘buddyblog_show_posts_on_profile’ and decide which posts should be linked on the profile and which should not be.
Hope that helps.
- This reply was modified 9 years, 9 months ago by
Brajesh Singh.
- This reply was modified 9 years, 9 months ago by
- Brajesh Singh on January 12, 2016 at 3:27 pm in reply to: [Resolved] BBpress – restrict topic creation #2296
Hi Joshua,
Do you want to restrict the users from creating in all forums and just reply(It is easy) or on specific forum only?My own solution was a bit mixed with template, so not very useful here but there are filters, if it is the first case, It will be super easy to do.
- Brajesh Singh on January 12, 2016 at 3:25 pm in reply to: BP Gallery – Add from web not working with Internet Explorer #2295
Thank you. I will have an update. Will be testing on my other system and will get back to you.
Thank you
Brajesh Hi Peter,
I will have a definite solution today.Sorry to keep you waiting for long.
Hi Rodolfo,
At the moment, BP Simple Front end post editor does not support post excerpts. It is possible to add extra content section using custom fields though.Would you like to add extra content section using custom field for now? I will add the excerpt support in simple front end post plugin in future.
Thank you
Brajesh- Brajesh Singh on January 12, 2016 at 7:03 am in reply to: BP Gallery – Add from web not working with Internet Explorer #2289
Hi George,
Which version of Internet explorer is giving error and what error do you see there? The MediaPress audio/video cover upload is complete now and available on github. Working on next.
Hi, Just updateting.
I spent yesterday working on allowing MediaPress to attach cover images to Audio/Video. It is a little left and I will be finishing any time soon today and push to github them.After that, I will work on the importer today. Sorry for all these delays.
- Brajesh Singh on January 11, 2016 at 8:58 am in reply to: Could blog-categories-for-groups post to a groups activity stream? #2284
Hi Jan,
Tank you and my best best wishes for you for the new year too 🙂There is a new ticket going on BuddyPress trac
https://buddypress.trac.wordpress.org/ticket/6795That will make it easy to handle the activity stream integration of posts/post types.
In the mean time, I have been continuously enhancing blog categories plugin( changes are not available on Buddydev but is available on our git repository). I certainly look forward to add the activity stream capability soon too.
- Brajesh Singh on January 11, 2016 at 8:53 am in reply to: [Resolved] BBpress – restrict topic creation #2283
Hi Joshua,
Thank you for asking.
I did it for one of my sites. I will look into the code and post it today( a little late today )Thank you
Brajesh