Shape the future of Social networking with WordPress: Join Project Midnight Sun! The next generation platform for community building with WordPress!

BuddyDev

Search

Replies

  • Keymaster
    (BuddyDev Team)
    Posts: 25267

    You are most welcome. It is available in the WordPress.org repo now 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 25267
    Brajesh Singh on in reply to: [Resolved] Delete image redirect #3054

    Hi,
    It is available on wp.org now. Please upgrade.

  • Keymaster
    (BuddyDev Team)
    Posts: 25267

    Hi,
    1.0.4 is now available on WordPress.org and this feature is included. Marking it as resolved.

  • Keymaster
    (BuddyDev Team)
    Posts: 25267
    Brajesh Singh on in reply to: Mediapress lightbox #3052

    Hi,
    It is available now from wp.org. I have just pushed the new version there. Please visit your Plugins->Installed and you will see the notification to update.

  • Keymaster
    (BuddyDev Team)
    Posts: 25267

    Thank you for the kind words and confirming that it works.
    I am happy that I was able to help.
    Hoping that you have a great experience building your site 🙂

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25267

    Hi Kenneth,
    Thank you for your patience. Please upgrade to 1.2.1 and It is fixed. Please do let me know if that works for you or not?

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25267

    Thank you Kenneth,
    Just noticed it on BP 2.5+ It has issues with loading templates. I am working on it, will have a fix in 30 mins to an hour. It is happening when the theme compat is being triggered.

  • Keymaster
    (BuddyDev Team)
    Posts: 25267

    Hi Kenneth,
    Welcome to BuddyDev.
    Which version of BuddyPress & WordPress are you using? Also, are you using latest version of change username plugin?

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25267

    Hi Hamish,
    You will need to translate using languages file.

  • Keymaster
    (BuddyDev Team)
    Posts: 25267

    Hi Hamish,
    Welcome to BuddyDev.
    Thank you for asking it. I had posted the code somewhere but could not find it on the forum, so posting again. Please put these codes in your bp-custom.php

    1. Let us write a function to create a category with group name and save it as bcg category for group(you won’t need the code you have used in the above post)

    
    
    /**
     * Create a Category with group name and set as BCG category
     * 
     * @param type $group
     * @return type
     */
    function bcg_custom_create_group_category( $group ) {
    		
    	$cat = wp_insert_term( $group->name, 'category' );
    
    	if ( ! is_wp_error( $cat ) ) {
    		//insert it to group meta for blog categories
    		groups_update_groupmeta( $group->id, 'group_blog_cats', array( 0 => $cat['term_id'] ) );
    		
    		return array( 0 => $cat['term_id'] );
    
    	} else {
    		//is it existing
    		$term = get_term_by( 'slug', $group->slug,  'category' );
    		if (  $term ) {
    			
    			groups_update_groupmeta( $group->id, 'group_blog_cats', array( 0 => $term->term_id ) );
    			
    			return array( 0 => $term->term_id );
    		}
    	}
    	
    	
    	return false;
    	
    }
    
    

    2. Let us Create the category and setup it when the group is create

    
    
    //Blog Categories for Groups, auto category creation and association
    function bcg_custom_create_group_name_category( $group_id, $group ) {
    
    	bcg_custom_create_group_category( $group );
    }
    
    add_action( 'groups_created_group', 'bcg_custom_create_group_name_category', 10, 2 );
    

    3. Disable the Blog Categories screen on Create Group and Grou Admin settings page

    
    //modify extensions to hide the create/manage screen
    function bcg_custom_modify_extension( &$extension ) {
    	
    	 $extension->enable_create_step = false; // enable create step
    	 $extension->enable_edit_item = false; // If 
    }
    add_action( 'bcg_created_group_extension', 'bcg_custom_modify_extension' );
    

    4. Modify the BCG form to add a hidden field and set post status to publish(we will use hidden field to set the forced category)

    
    
    function bcg_custom_forms_args( $args ) {
    	
    	$args['tax'] = array();
    	
    	$cusom_fields = isset( $args['custom_fields'] ) ? $args['custom_fields']: array() ;
    	
    	$group = groups_get_current_group();
    	
    	if( empty( $group ) || empty( $group->id ) ) {
    		return $args;
    	}
    	
    	$cats = bcg_get_categories( $group->id );
    	//if there is no category set
    	if( empty( $cats ) ) {
    		//create if not exists
    		$cats = bcg_custom_create_group_category( $group );
    	}
    	
    	if ( empty( $cats ) ) {
    		return $args;
    	}
    	
    	$cusom_fields['_bcg_selected_category'] = array(
    		'type'		=> 'hidden',
    		'default'	=> $cats[0],
    		'label'		=> ''	
    	);
    	
    	$args['custom_fields'] = $cusom_fields;
    	$args['post_status'] = 'publish';
    	
    	return $args;
    }
    add_filter( 'bcg_form_args', 'bcg_custom_forms_args' );
    
    

    5. Set the Category

    
    
    //set default categorywhen post is being saved
    function bcg_add_default_category_to_post( $post_id ) {
    	
    	$post = get_post( $post_id );
    	
    	if ( ! $post ) {
    		return ;
    	}
    	
    	$custom_fields = isset( $_POST['custom_fields'] ) ? $_POST['custom_fields'] : array();
    	
    	if ( empty( $custom_fields ) ) {
    		return ;
    	}
    	
    	if ( ! empty( $custom_fields[ '_bcg_selected_category'] ) ) {
    		
    		$term_id = absint( $custom_fields['_bcg_selected_category'] );
    		//i know there is a loop here that can allow other categories to be asosciated too
    		//to avoid that we need the group id in future
    		wp_set_object_terms( $post->ID, $term_id, 'category');
    	
    	}
    
    }
    
    add_action( 'bsfep_post_saved', 'bcg_add_default_category_to_post' );
    
    

    That will do everything.

    It will remove the screens and auto set category name as well as set category for posts.

    Please do let me know if that works for you or not?

    Thank you
    Brajesh