BuddyDev

Search

Importing Gallery comments

  • Participant
    Level: Initiated
    Posts: 1
    Geoff Beale on #52182

    I am migrating a Drupal 7 site and working on a plugin to import the galleries from a CSV file. All going well and can create a gallery and add media. However I can’t work out if I can import comments that other users have made on the media items. Could someone point me in the right direction, many Thanks!

  • Keymaster
    (BuddyDev Team)
    Posts: 24237
    Brajesh Singh on #52193

    Hi Geoff,
    Welcome to BuddyDev.

    Thank you for the question.

    The media comments are actually BuddyPress Activity entries.

    We add an activity meta key _mpp_media_id and its value is the numeric media id to which this activity belongs.
    We also set the type of the activity to mpp_media_upload

    Hope that helps.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 1
    Geoff Beale on #52199

    Thanks very much for that Brajesh.

    Made some progress on this and have managed to add a to a gallery but when I attempt to add a comment to an individual media item the gallery appears at gallery level not on the media item.

    Here’s my code:

    `$new_activity_id = mpp_media_record_activity( array(
    ‘media_id’ => $new_file_id,
    ‘type’ => ‘media_comment’,
    ‘context’ => ‘media’,
    ‘user_id’ => 5,
    ‘content’ => ‘The first imported media comment’,
    ) );`

    I would be grateful if you could point out my error, thanks.

  • Keymaster
    (BuddyDev Team)
    Posts: 24237
    Brajesh Singh on #52207

    Hi Geoff,
    Thank you for the reply.
    I am sorry for the delay.

    It is a bit complicated for the media comment.

    Please take a look at MPP_Ajax_Comment_Helper::post_comment for how are we creating comment for media.

    https://github.com/buddydev/mediapress/blob/master/core/ajax/class-mpp-ajax-comment-helper.php#L59

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved