Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

  • davehakkens
    Participant

    @davehakkens

    OK, we got it to work in a different way. Special thanks to @coffeywebdev for the help.
    For those interested:

    This snippet is used in the functions.php to get the locations from the profile fields and show the flag image.

    function dh_get_flag_by_location($country){
      if($country <> '' && !empty($country)){
      $country_filename = get_stylesheet_directory_uri() . '/img/flags/' . sanitize_file_name($country) . '.png';
      $country_path = get_stylesheet_directory() . '/img/flags/' . sanitize_file_name($country). '.png';    
         if(file_exists($country_path)){
           $html = '<img src="' . $country_filename . '"/>';
         } else {
           $html = $country;
           echo '<!--' . get_stylesheet_directory_uri() . '/img/flags/' . sanitize_file_name($country) . '-->';
        }
      echo $html;
      }
    }

    Then we needed to change 2 templates to show this flag image in
    the Bbpress forum replies and on the buddypress members page. So we added the code necessary to show the flag
    bbpress/loop-single-reply.php
    <div id="country" style="float:left;margin-right:.5em;"> <?php $user = get_userdata( bbp_get_reply_author_id() ); $country = xprofile_get_field_data( 42, $user->ID ); dh_get_flag_by_location($country); ?></div>

    buddypress/members/members-loop.php
    <div class="member-location"> <?php $country = bp_get_member_profile_data('field=Location'); dh_get_flag_by_location($country); ?></div>


    davehakkens
    Participant

    @davehakkens

    Still doesn’t work.
    Here is an example of the page where it should be displayed. Am I missing something?


    davehakkens
    Participant

    @davehakkens

    Also doesn’t seem to work from the bpcustom.php 🙁

    Thanks for the link, never tried groups. Seems powerful though..


    davehakkens
    Participant

    @davehakkens

    What do you mean with standalone version @danbp? I use a bbpress and buddypress plugin. I figured this is more for Buddypress since it has to do with buddpress profile fields.

    Anyway thanks for the code, looks good! But it doesn’t seem to work after adding it into the functions.php. I haven’t got experience using filters so can’t seem to find the problem..


    davehakkens
    Participant

    @davehakkens

    thanks for the help @djpaul.

    <div id="country"> <?php echo bp_get_member_profile_data(array('field'=>'country', 'user_id' => bbp_get_reply_author_id())); ?></div>
    

    However this code results in showing the location of the user itself, me.
    Not the user that made the reply.

Viewing 5 replies - 1 through 5 (of 5 total)
Skip to toolbar