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: 25285

    Thank you.

    In order to update the gallery details, you can use the following function(s)

    Updating gallery status(If you only need to update status)

    
    mpp_update_gallery_status( $gallery, $status ); // $status can be any valid status e.g 'public', 'private' etc.
    
    

    Or you can use

    
    mpp_update_gallery( $args );
    
    

    where $args can be

    
    $args = array(
    	'id'           => $gallery_id, // *Required
    	'title'        => 'gallery title', // optional, if not given, keeps the current gallery title.
    	'description'  => 'gallery description', //optional.
    	'slug'         => 'gallery-unique-slug',
    	'creator_id'   => $user_id,//who created this gallery.
    	'order'        => 0, // menu order.
    	'component_id' => $user_id,//optional. will keep current component if not given.
    	'component'    => 'sitewide', // optional
    	'status'       => 'public', //new status
    	'type'         => 'photo', //new type?
    );
    
    

    Everything except the id is optional.

    For example, Here is how we are updating the gallery description.

    https://github.com/buddydev/mediapress/blob/master/core/ajax/mpp-ajax.php#L1049

    Hope that helps.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25285

    Thank you for the update.

    You can do that by using the following code

    
    $associated_gallery_id = get_post_meta( $post_id, '_mppc_associated_photo_gallery_id', true );
    
    

    You should use the actual post id for fetching gallery id.

  • Keymaster
    (BuddyDev Team)
    Posts: 25285

    Thank you Graham.

    I am glad I was able to fix it in time.

    Thank you for your patience and helping me in making MediaPress better 🙂

    Best regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25285

    Thank you George.
    I am looking forward to your feedback 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    Brajesh Singh on in reply to: Title of images breaks grid view #12719

    Hi Monsur,
    I am sorry, I forgot about it. Will test today and get back to you.

    regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    Brajesh Singh on in reply to: Get messages for user receive #12718

    Hi Rossini,
    what you are looking for is

    https://github.com/buddypress/BuddyPress/blob/master/src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php

    Please take a look at the template for all available options.

  • Keymaster
    (BuddyDev Team)
    Posts: 25285

    Hi George,
    Here is an example that creates a gallery each time a post is published

    
    
    /**
     * Auto Create Custom photo gallery when new post is created.
     *
     * @param int $post_id post id.
     * @param WP_Post $post post object.
     */
    function mpp_custom_create_update_associated_gallery( $post_id, $post ) {
    	// Only test for already published posts.
    	if ( 'publish' != $post->post_status ) {
    		return;
    	}
    
    	// we only want to create gallery for 'post' post type
    	// change 'post' with your own post type name.
    	if ( 'post' != $post->post_type ) {
    		return;
    	}
    
    	$associated_gallery_id = get_post_meta( $post_id, '_mppc_associated_photo_gallery_id', true );
    
    	$user_id = $post->post_author;// or should we use get_current_user_id() ?
    	if ( $associated_gallery_id ) {
    		// wht do you want to do?
    		//
    		return;
    	}
    
    	// if we are here, the gallery does not exist, let us create it.
    
    	$gallery_id = mpp_create_gallery( array(
    		'creator_id'   => $user_id,
    		'title'        => $post->post_title,
    		'description'  => '',
    		'status'       => 'public',
    		'component'    => 'sitewide',
    		'component_id' => $user_id,
    		'type'         => 'photo',
    	) );
    
    	// save a reference to post in gallery meta?
    	// and a reference of gallery to post meta?
    	if ( $gallery_id ) {
    		mpp_update_gallery_meta( $gallery_id, '_mppc_associated_post_id', $post_id );
    		update_post_meta( $post_id, '_mppc_associated_photo_gallery_id', $gallery_id );
    	}
    }
    
    add_action( 'save_post', 'mpp_custom_create_update_associated_gallery', 10, 2 );
    

    You can update it to match for your own post type.
    Hope it helps.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25285
    Brajesh Singh on in reply to: [Resolved] Stats Feed #12715

    Thank you for marking it resolved.