Replies
- Brian on September 20, 2016 at 3:40 am in reply to: [Resolved] Limit Number of Galleries Per User? #5722
Any update on this Brajesh? Would love to incorporate this.
Thank you.
- Brian on September 9, 2016 at 5:07 pm 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 🙂 - Brian on August 14, 2016 at 3:25 pm in reply to: [Resolved] Detect if user has media in gallery? #5098
Excellent Brajesh, Thank you very much. Works great!
Perfect, thank you!
Works great.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.
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
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 🙂
- Brian on May 18, 2016 at 9:24 pm in reply to: [Resolved] Automatically Create New Post for Every New BuddyPress Registration #3949
Yes!!
That worked.
Thanks a bunch Ravi!
- Brian on May 18, 2016 at 9:17 pm in reply to: [Resolved] Automatically Create New Post for Every New BuddyPress Registration #3945
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.
- Brian on May 18, 2016 at 8:15 pm in reply to: [Resolved] Automatically Create New Post for Every New BuddyPress Registration #3940
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’ => $bandnameBut 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!