BuddyDev

Search

[Resolved] mpp_add_media Items Not Showing in Shortcode Media Query

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on #5907

    In response not being able to have more than one uploader shortcode on my page:
    https://buddydev.com/support/forums/topic/not-able-to-add-more-than-one-uploader-shortcode-to-page/

    I’m looking into creating custom WP_Ajax front-end file submission of my own which utilizes wp_upload_bits to get the filepath url and mpp_add_media to add the uploaded file into a MediaPress gallery.

    for mpp_add_media I am customizing the $media_data array as shown here:
    https://buddydev.com/support/forums/topic/custom-gallery-from-buddypress-fields/

    This is working great, and my file (in my case, audio file), is being uploaded and placed into the appropriate MediaPress gallery.

    I am able to see this newly uploaded file when I log into my BuddyPress profile > Gallery > My Audio Gallery.
    This file is being listed and can be played among the rest of the traditionally-updated Audio files.

    My issue is that when trying to output the audio files in a audio playlist shortcode (mpp_shortcode_get_media_data(‘query’), $query->have_media(), $query->get_ids(), etc), my custom uploaded files are not appearing here.

    Am I missing something with this?
    Thank you!

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on #5908

    To clarify, if not clear, these custom uploaded files are showing up just fine in my admin backend and buddypress profiles in appropriate gallery with all the others, but not showing up when using mpp-list-media, or more specifically [mpp-list-media type=audio view=playlist user_id=’.$userid.’]

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on #5909

    Okay so looking at mpp-media-functions.php
    https://github.com/buddydev/mediapress/blob/master/core/media/mpp-media-functions.php

    Maybe I should update metadata

    mpp_update_media_meta( $id, ‘_mpp_is_mpp_media’, 1 );
    wp_update_attachment_metadata( $id, mpp_generate_media_metadata( $id, $src ) );

    as well? But it still is not showing up on my query/shortcode playlist

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on #5911

    Nevermind, turns out this wasn’t a MediaPress issue at all.
    I used mpp_media_to_json and compared the two uploads styles.
    Noticed the ‘author’ wasn’t setting in correct for my ajax uploads.
    So just simply added

    $setpostauthor = array(
    ‘ID’ => $id,
    ‘post_author’ => 470
    );
    wp_update_post( $setpostauthor );

    to my function and now they show up in the playlist query.

    • This reply was modified 6 years, 2 months ago by Brian.
  • Keymaster
    (BuddyDev Team)
    Posts: 22218
    Brajesh Singh on #5915

    Hi Brain,
    I am glad you have resolved it.

    To set author, you can pass “user_id” in the mpp_add_media.

    If you can post the complete code(mpp_add_media array), I will be able to help much better.

    Also, to make a media appear everywhere it needs to be marked as non orphan, and must have a component, status, type associated.

    Hope that will help in future.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on #5927

    Thanks for the tidbit on the orphan attribute, wasn’t sure what that was about.
    I am passing $user_id in my array, but I think because I am logged in as admin while on localhost/development it’s for whatever reason overriding it. Anyways, this won’t be an issue when I move out of development testing, so I’m not worried about it.

    Everything else is working great. Was able to make my own custom front-end form like

    [Song Title] (text field)
    [Audio File Upload] (audio file input)
    [Album Cover] (image file input)

    And just tested and they immediately go into the MediaPress gallery and shortcode listing with the three inputs. Still have to optimize it, but i’m happy it’s what I wanted 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 22218
    Brajesh Singh on #5952

    Thank you Brian. I am glad. It is always a pleasure to see MediaPress being useful. All the best with the project 🙂

The topic ‘ [Resolved] mpp_add_media Items Not Showing in Shortcode Media Query’ is closed to new replies.

This topic is: resolved