BuddyDev

Search

Replies

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on in reply to: [Resolved] Limit Number of Galleries Per User? #5722

    Any update on this Brajesh? Would love to incorporate this.

    Thank you.

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on in reply to: [Resolved] Limit Number of Galleries Per User? #5506

    Thank you so much Brajesh, you’re the best.
    Waiting patiently for your next reply 🙂

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on in reply to: [Resolved] Detect if user has media in gallery? #5098

    Excellent Brajesh, Thank you very much. Works great!

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on in reply to: [Resolved] Featured Images in MediaPress? #4697

    Perfect, thank you!
    Works great.

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on in reply to: [Resolved] Featured Images in MediaPress? #4694

    Actually, I’ve encountered another problem.

    It seems my function is not returning correct thumbnail id from image url.

    I checked manually and the thumbnail id for the image I’m getting through the url and it is ‘3447’

    $thumb_id = get_attachment_id_from_src($thumb_url);

    $thumb_id is for some reason outputting an ID of 1627. Not sure where it is getting this ID from, but it is not correct and not working because of this..

    Still looking into this.

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on in reply to: [Resolved] Featured Images in MediaPress? #4693

    Hello,

    I was able to find thumbnail ID via the following,

    in functions.php:

    function get_attachment_id_from_src ($image_src) {
    global $wpdb;
    $query = “SELECT ID FROM {$wpdb->posts} WHERE guid=’$image_src'”;
    $id = $wpdb->get_var($query);
    return $id;
    }

    then on page:

    $thumb_id = get_attachment_id_from_src($thumb_url);

    It’s weird… I stumble for hours one day, only to come back to it the next and immediately stumble upon the answer

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on in reply to: [Resolved] Featured Images in MediaPress? #4689

    Thank you Brajesh.

    Correct me if I’m wrong, but since I am using the shortcode ‘[mpp-list-media user_id=.$variable.]’ in the post, and not directly attaching MediaPress images to the post itself, it is not acting like a normal WordPress attachment.
    More specifically, users add images to their BuddyPress profile, and the shortcode is assigned to their individual post.

    Anyways,
    Usage for ‘set_post_thumbnail()’ is as followed:

    <?php set_post_thumbnail( $post, $thumbnail_id ); ?>

    Getting the Post ID for $post is easy ($post = get_the_ID();)

    But I am confused on obtaining the thumbnail id for the MediaPress image.

    I am able to retrieve the Image URL by doing the following:
    $thumb_url = mpp_media_src( ‘full’ );
    echo $thumb_url[0];

    But this does not help me in finding the thumbnail ID..

    Any advice on how to obtain a thumbnail ID from MediaPress shortcode gallery?

    My apologies if this is a noob question.. I am somewhat new to WordPress and PHP. Spent several hours trying to wrap my head around this but still confused.

    TY 🙂

  • Participant
    Level: Enlightened
    Posts: 31

    Yes!!

    That worked.

    Thanks a bunch Ravi!

  • Participant
    Level: Enlightened
    Posts: 31

    Checked MySQL tables and the field for Band Name is just simply “1”.

    Tried your code to echo out in profiles.php. Worked perfectly.

    Tried the code in bp-custom.php and still outputs (no title).

    Maybe since bp-custom.php loads before the page it is not seeing logged in user id?

    edit: just saw your new reply. Will update in a minute

    • This reply was modified 8 years, 6 months ago by Brian.
  • Participant
    Level: Enlightened
    Posts: 31

    Hi Ravi,

    Thanks for the tip. I tried this and it is working properly to add a new post on user activation.

    Do you know of a way to get user data for the Title field?

    I am trying like

    $userid = bp_loggedin_user_id();
    $bandname = xprofile_get_field_data( ‘Band Name’, $userid, $multi_format = ‘comma’ );
    ….
    ‘post_title’ => $bandname

    But it seems it is not parsing this information properly as post title output is ‘(no title)’.

    I am trying this with BP-AutoLogin-On-Activation plug-in so the user is logged in upon activation https://buddydev.com/plugins/bp-autologin-on-activation/

    Any tips?

    Thank you!