WordPress.org

Ready to get started?Download WordPress

Forums

Buddypress Xprofile Custom Fields Type
[resolved] Calling Image URL from Profile Field (9 posts)

  1. The Gal
    Member
    Posted 1 year ago #

    I found this thread asking the exact same question: http://wordpress.org/support/topic/echo-only-image-url

    However, though it's only a month old, I don't see the FAQ listing mentioned in the solution. I only see 3 FAQs, none of them associated with calling the data from the profile fields in any way.

    Is there a trick to this, or is it like calling any other profile field?

    Thanks so much!!

    http://wordpress.org/extend/plugins/buddypress-xprofile-custom-fields-type/

  2. donmik
    Member
    Plugin Author

    Posted 1 year ago #

    It's not in the faq, the faq only shows an example using the filter. For your case, if you want to show only image url, try this:

    add_filter( 'bxcft_show_field_value', 'my_show_field', 15, 4);
    function my_show_field($value_to_return, $type, $id, $value) {
        if ($type == 'image') {
            $uploads = wp_upload_dir();
            $value = str_replace("<p>", "", $value);
            $value = str_replace("</p>", "", $value);
            $value_to_return = '<p>'.$uploads['baseurl'].$value.'</p>';
        }
        return $value_to_return;
    }
  3. The Gal
    Member
    Posted 10 months ago #

    Hello there!

    First off, thank you so much for the reply! Secondly, I'm so sorry it took so long for me to reply as well. This project got stuck on a back burner due to other unrelated issues arising.

    OK, so thank you for the bit of code! It pulls the url instead of the image perfectly in the normal field.

    However, what I'm wanting is to pull that url outside of the field and not show the field in the normal profile list at all.

    I've already put together the basic php for where I want to pull it. You can see the mock-up here: http://www.pureplayhaven.com/members/Afton/profile/

    The banner image is the uploaded image from your plugin, but I'm just using the actual url and it'll be showing up on all the profiles, so obviously that isn't going to work. lol

    Do you have any hints on how to achieve what I'm going after?

    Thanks so much!!

  4. donmik
    Member
    Plugin Author

    Posted 10 months ago #

    I'm not sure I understand you.

    So, one member will upload this banner and you want to show this banner url to all profiles?

  5. The Gal
    Member
    Posted 10 months ago #

    lol Oh dear, my apologies for being confusing.

    What I would like is for every member to be able to upload an image and that image displays on their profile, in the profile header. Basically like a FB Timeline photo.

    I've already coded out the place I want the uploaded image to be and threw in a sample image for testing purposes, but I'm still trying to figure out how to output the uploaded image url outside the usual profile field output list.

  6. donmik
    Member
    Plugin Author

    Posted 10 months ago #

    Ok, I think I understand now.

    You can do it. If you are in the member's page, you can use:

    bp_member_profile_data('field=Image');

    You can see this code in your member-header.php. Search in your theme /members/single/member-header.php.

    /***
      * If you'd like to show specific profile fields here use:
      * bp_member_profile_data( 'field=About Me' ); -- Pass the name of the field
      */
  7. The Gal
    Member
    Posted 10 months ago #

    THANK YOU SO MUCH!!!! That pretty much did it! I ended up needing to add the absolute path to the upload site as well, so this is what I ended up with:

    function store_banner() { ?>
    <div class="storebanner">
    <img src="http://www.pureplayhaven.com/wp-content/uploads/<?php bp_member_profile_data('field=Banner Image'); ?>" />
    </div>
    <?php }
    add_action('bp_before_member_header','store_banner');

    And that did the trick!

    Thank you so much!!

  8. The Gal
    Member
    Posted 10 months ago #

    THANK YOU SO MUCH!!!! That pretty much did it! I ended up needing to add the absolute path to the upload site as well, so this is what I ended up with:


    function store_banner() { ?>
    <div class="storebanner">
    <img src="http://www.pureplayhaven.com/wp-content/uploads/<?php bp_member_profile_data('field=Banner Image'); ?>" />
    </div>
    <?php }
    add_action('bp_before_member_header','store_banner');

    And that did the trick!

    Thank you so much!!

  9. donmik
    Member
    Plugin Author

    Posted 10 months ago #

    You're welcome ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic