BuddyDev

Search

[Resolved] BP Simple Front End Post Form

  • Participant
    Level: Enlightened
    Posts: 79
    Leo on #3330

    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 form

    Can 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,
    Leo

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #3331

    Hi Leo,

    Thank You for posting. I am looking into this issue and will update you shortly.

    Thank You
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #3332

    Hi 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, 7 months ago by Ravi.
  • Participant
    Level: Enlightened
    Posts: 79
    Leo on #3334

    Hi Ravi, thank you, it works perfect now!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #3335

    Hi Leo,

    Thank you for confirming. I am glad that i could help

  • Participant
    Level: Enlightened
    Posts: 79
    Leo on #3416

    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,
    Leo

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #3419

    Hi Leo,

    Are you using WPML plugin. If yes I am sorry. I may not be help you with this plugin.

    Thank you
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #3420

    Hi Leo,

    Are you using WPML plugin?. If yes I am sorry. I may not be help you with this plugin.

    Thank you
    Ravi

  • Participant
    Level: Enlightened
    Posts: 79
    Leo on #3421

    Hi 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,
    Leo

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #3423

    Hi 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.

This topic is: resolved