BuddyDev

Search

by Brajesh Singh

Permalink: #230

BuddyBlog change settings example to post to single category and some more

add_filter('buddyblog_post_form_settings', 'buddyblog_custom_form_settings');
function buddyblog_custom_form_settings( $settings ){

    unset( $settings['upload_count'] );
    unset( $settings['tax'][ 'post_tag'] );//no need to show posts tag

    $category = get_category_by_slug( 'blog' );

    $settings['tax']['category']['include'] = array( 0 => $category->term_id );

  return $settings;  
}

@buddyblog #buddypress #buddyblog

by Brajesh Singh

Permalink: #221

BuddyBlog Redirect to single post on new post creation or post update


//redirect to single post on save/update //in future, I will add two different options for new post/update post add_action( 'bsfep_post_saved', 'buddyblog_redirect_on_post' ); function buddyblog_redirect_on_post( $post_id ){ $post = get_post( $post_id ); $post_type = get_post_type( $post ); $post_type_details = get_post_type_object( $post_type ); $message = sprintf( __( '%s Saved as %s successfully.', 'bsfep' ), $post_type_details->labels->singular_name, get_post_status( $post_id ) ); bp_core_add_message( $message ); bp_core_redirect( get_permalink( $post_id ) ); }

@buddyblog #buddypress #buddyblog

by Brajesh Singh

Permalink: #212

Show Posts from a perticular category only on user profile, other should link to the main site when using BuddyBlog

add_filter( 'buddyblog_show_posts_on_profile', 'buddyblog_custom_permalinks_filter', 10, 2 );
function buddyblog_custom_permalinks_filter( $do_filter, $post ){

    $category = get_category_by_slug( 'blog' );

    $post_categories = get_the_category( $post->ID );

    $post_cat_ids = wp_list_pluck( $post_categories, 'term_id' );
    //if it is in blog category, show on profile
    if( in_array( $category->term_id, $post_cat_ids ) )
            return true;

    return $do_filter;

}

#buddypress #buddyblog @buddyblog