Hi Brajesh,
I have BuddyBlog and BP Simple Frond End Post plugins installed on my website and they both work perfect.
I have the below filter in functions.php file, which limits the categories to the cat id=6 :
/** limit buddyblog categories **/
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' => 'checkbox',
'include' => array( 6 ), //CHANGE with the correct IDs
'orderby' => 'slug',
'order' => 'ASC'
);
$settings['tax'] = $tax;
return $settings;
}
/** END buddyblog categories **/
In WP admin – Settings – BuddyBlog I have “Select allowed taxonomies” Categories unchecked.
also, from BP Simple Front End Post plugin’s form.php, I have removed the categories part.
So, now, any user publishes a post, it goes under the 6th category. That’s what I want.Now, I have created another category and another form for users to publish posts in this category only (id=193).
here’s the form code (from the plugin page) in my functions.php :
/* bp simple from end post form */
add_action( 'bp_init', 'my_post_form', 4 );function my_post_form() {
$settings = array( 'post_type' => 'post',
'post_author' => bp_loggedin_user_id(),
'post_status' => 'publish',
'current_user_can_post' => is_user_logged_in(),
'show_categories' => true,
'allowed_categories' => array( 193 )
);
$form = bp_new_simple_blog_post_form( 'my form', $settings );
}
and this is where the form should appear:
$form = bp_get_simple_blog_post_form('my form');
if ( $form ) { $form->show(); }
And here there are 2 problems I can’t solve:
1. when I try to publish a post from the new form, the posts go under the uncategorzed category
2. there’s no ‘Add media’ button in the new formCan you please check and let me know how to fix these 2 issues?
I use Buddyblog 1.1.5 and BP Simple Front End Post 1.2.7 versions.
Thank you,
LeoHi Leo,
I have done some modification to the code. Please check it now
function buudydev_post_form() { $settings = array( 'post_type' => 'post', 'post_author' => bp_loggedin_user_id(), 'post_status' => 'publish', 'tax' => array( 'category' => array( 'include' => array( 61 ), //category ids 'view_type' => 'checkbox', ) ), 'current_user_can_post' => is_user_logged_in(), 'show_categories' => true, 'allow_upload' => true ); bp_new_simple_blog_post_form( 'my_custom_form', $settings ); } add_action( 'bp_init', 'buudydev_post_form', 4 ); //to show form bp_get_simple_blog_post_form('my_custom_form')->show();
Thank You
Ravi- This reply was modified 8 years, 8 months ago by Ravi.
Hi Ravi,
I have another problem here, can you please have a look?
When I fill the form and submit, the page loads and the new post is already there in English – default language.
But when I submit the form in Spanish, the page show’s a 404 page under the same URL, after a reload, the page loads again.Any ideas why this may happen?
Thank you,
LeoHi Ravi,
Thanks for your reply. Yes I use WPML, so I will try to find it out.
Another question, please, in user profile tabs next to BuddyBlog there’s the number of posts by a user. I need to show there only the number of posts in one category. Is that possible?
I checked it gets the number from wpdb where the categories are not included in the posts table. Are you aware of another way to get this?Thank you,
LeoHi Leo
Yes it can be done. Please override the posts list template. You can override template by copy “buddyblog/template/buddyblog/posts.php” file to your theme folder “buddyblog/posts.php” after copying, modify the following section
$query_args = array( 'author' => bp_displayed_user_id(), 'post_type' => buddyblog_get_posttype(), 'post_status' => $status, 'paged' => intval( $paged ) );
to
$query_args = array( 'author' => bp_displayed_user_id(), 'post_type' => buddyblog_get_posttype(), 'post_status' => $status, 'category__in' => array(65), //category ids of the selected post-types 'paged' => intval( $paged ) );
Thank You
Ravi
The topic ‘ [Resolved] BP Simple Front End Post Form’ is closed to new replies.