BuddyDev

Search

[Resolved] Adding a gallery automatically on post creation

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12720

    Thanks Brajesh, you are a star! I’ll get onto this later today

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #12723

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

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12726

    Working on it now, I’ve got it half working, it’s creating the gallery, I just need to work on adding the gallery ID to my shortcode fields

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #12727

    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.

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12728

    Yep that works great!

    Now I have more to ask of you I’m afraid. I will need to set the privacy options from public to private after the post has been created, to you have a function for that?

    I’m going to include a drop down in the post where the author can change the privacy of the gallery from public to private. I think I can handle most of the code for that, I just need to know te function to use for editing the gallery details.

    Thanks

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12729
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #12730
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #12731

    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

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12732

    Thaks, I’ll work on that and let you know how it goes

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #12733

    sure, I am looking forward to it 🙂

The topic ‘ [Resolved] Adding a gallery automatically on post creation’ is closed to new replies.

This topic is: resolved