BuddyDev

Search

Need to add custom BuddyBlog new post fields

Tagged: 

  • Participant
    Chirag Sharma on #3854

    Hi There,
    This is one plugin that has made my life so easy. The BuddyBlog plugin works great on my website. However, there are two things that I would like to achieve and I am hoping to get some of your help.

    In the New Post form, I don’t want to see the “Add Media” button. But instead, I want to see a field to enter a Video URL. So say, right below Title, there’s another field where the user can enter a video URL (YouTube, Vimeo, etc)

    Also, whenever a user submits a new post, it is reflected as a “standard” format post. My theme comes with other options such as gallery, video and audio. I would like to set the default post format as “video” whenever a user submits a post.

    I would really help your support as this is the only outstanding item on my project. Cheers!!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2489
    Ravi on #3856

    Hi Chirag,

    Thank You posting. You can disable ‘Add Media’ from BuddyBlog plugin setting under setting in backedend. Check Allow Upload setting and sat it to NO. It will disable the ‘Add Media’ button.

    Please use the following code in your bp-custom.php file.

    
    function buddydev_change_post_format( $post_id ) {
        set_post_format( $post_id, 'video' );  // set the default post format here
    }
    add_action('bsfep_post_saved','buddydev_change_post_format');
    
    function buddydev_video_field( $settings ){
        // extra field for video url
        $settings['custom_fields']['_video_url'] = array(
            'type'    => 'textbox',
            'label'   => 'Enter Video Url',
            'default' => ''
        );
        
        return $settings;
    }
    add_filter('buddyblog_post_form_settings','buddydev_video_field', 10 );
    
    

    to render the content of this post use the following code

    
    function buddydev_filter_content( $content ) {
        
        $video_url = get_post_custom_values( '_video_url', get_the_ID() )[0];
        
        if ( $video_url ) {
            $content .= $video_url;
        }
        return $content;
    }
    add_filter('the_content','buddydev_filter_content' );
    

    Please let me know if it works for you or not.

    Thank You
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved