This topic has 9 replies, 3 voices, and was last updated 8 years by Radu.

  • Author
  • #89531
     parousia
    Participant

    Hi!

    I’m using the code below to display a list of groups that belongs to the user. I would really like to be able to fetch the cover image for each group. Is there a way I can do that from within this code?

    outcome of the code can be seen here – http://www.cultexposure.com/members/lauriedugdale/

    Thanks!

    COPY CODE
    
                                $user_id = bp_displayed_user_id();
                                $getusername = your_name_or_company_name();         
    
                                if ( bp_has_groups( 'type=alphabetical&max=6&user_id=' . $user_id )) { ?>
    
                                    <div class="inner-right">
    
                                        <h3><?php echo $firstname; ?>'s <a href="http://www.cultexposure.com/members/<?php echo $getusername; ?>/groups/">groups</a></h3>
    
                                    <ul id="profile-group-list-wrap" class="my-groups-list item-list">
    
                                        <?php while ( bp_groups() ) : bp_the_group(); ?>
    
                                            <li class="profile-group-list">
                                                <div class="item-avatar">
                                                    <a href="<?php bp_group_permalink() ?>"><?php bp_group_avatar_thumb() ?></a>
                                                </div>
    
                                                <div class="item">
                                                    <div class="item-title"><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></div>
                                                    <div class="item-meta"><span class="activity"><?php bp_group_member_count() ?></span></div>
                                                </div>
                                            </li>
    
                                        <?php endwhile; ?>
                                    </ul>
                                    <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
                                    <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />
    
                                    <div class="homepage-btn">
                                        <a href="http://www.cultexposure.com/members/<?php echo $getusername; ?>/groups/"><span></span>Browse your groups</a>
                                    </div>
    
                                    </div>
                                <?php } ?>
    
    #89695
     Laura
    Moderator

    Hello, will assign the ticket to a higher support level who can help and advise you in your query.
    Thanks! 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #89859
     parousia
    Participant

    Thanks!

    #90081
     Radu
    Moderator

    Hi,

    Do you have solved your issue , i see in your page a block of groups with cover image.

    From you provided code this function it seems to be what you need

    COPY CODE
    
    bp_group_avatar_thumb()
    

    Cheers

    Radu

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #90177
     parousia
    Participant

    Hi, thanks but the avatar retrieving the avatar isn’t the problem, its the cover image of the group I would like. Is this possible?

    #90185
     Radu
    Moderator

    Hi,

    Sorry for misunderstanding,

    I will get back to you tomorrow with an solution regarding to this.

    Cheers

    Radu

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #90618
     parousia
    Participant

    Thanks! When needed I’ve been fetching the user profile cover from user meta, but I don’t think the group cover is stored anywhere like that?

    #90926
     Radu
    Moderator

    Hi,

    Try with this

    COPY CODE
    
        $image_url = groups_get_groupmeta( bp_get_group_id(), 'bpcp_group_cover' );
    
    

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #91083
     parousia
    Participant

    Unfortunately its not working?

    my code is below

    COPY CODE
    
                            <?php
                            $user_id = bp_displayed_user_id();
                            $firstname = your_name_or_company_name(true);
                            $getusername = bp_get_displayed_user_username();
                            $args = array(
                                 'type' => 'alphabetical',
                                 'max' => 6,
                                 'user_id' => $user_id
                            );
    
                            if ( bp_has_groups ( $args )) { ?>
    
                                <div class="inner-right">
    
                                    <h3><?php echo $firstname; ?>'s <a href="http://www.cultexposure.com/members/<?php echo $getusername; ?>/groups/">groups</a></h3>
    
                                    <ul id="profile-group-list-wrap" class="my-groups-list item-list">
    
                                        <?php while ( bp_groups() ) : bp_the_group(); ?>
                                        <?php $image_url = groups_get_groupmeta( bp_get_group_id(), 'bpcp_group_cover' ); ?>
                                            <li class="profile-group-list" style="background-image:url("<?php echo $image_url; ?>")" >
                                                <div class="item-avatar">
                                                    <a href="<?php bp_group_permalink() ?>"><?php bp_group_avatar_thumb() ?></a>
                                                </div>
    
                                                <div class="item">
                                                    <div class="item-title"><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></div>
                                                    <div class="item-meta"><span class="activity"><?php bp_group_member_count() ?></span></div>
                                                </div>
                                            </li>
    
                                        <?php endwhile; ?>
                                    </ul>
    
                                    <div class="homepage-btn">
                                        <a href="http://www.cultexposure.com/members/<?php echo $getusername; ?>/groups/"><span></span>Browse your groups</a>
                                    </div>
    
                                </div>
                            <?php } ?>    
    
    #91228
     Radu
    Moderator

    Hi,

    It works try now.

    COPY CODE
    
    <?php
    $user_id = bp_displayed_user_id();
    $getusername = bp_get_displayed_user_username();
    $args = array(
        'type' => 'alphabetical',
        'max' => 6,
        'user_id' => $user_id
    );
    
    if ( bp_has_groups ( $args )) { ?>
    
        <div class="inner-right">
    
            <h3><?php echo $firstname; ?>'s <a href="http://www.cultexposure.com/members/<?php echo $getusername; ?>/groups/">groups</a></h3>
    
            <ul id="profile-group-list-wrap" class="my-groups-list item-list">
    
                <?php while ( bp_groups() ) : bp_the_group(); ?>
                    <?php $image_url = groups_get_groupmeta( bp_get_group_id(), 'bpcp_group_cover' ); ?>
    
                    <?php print_r($image_url);?>
    
                    <li class="profile-group-list" style="background-image:url('<?php echo $image_url; ?>')" >
                                                <div class="item-avatar">
                                                    <a href="<?php bp_group_permalink() ?>"><?php bp_group_avatar_thumb() ?></a>
                                                </div>
    
                                                <div class="item">
                                                    <div class="item-title"><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></div>
                                                    <div class="item-meta"><span class="activity"><?php bp_group_member_count() ?></span></div>
                                                </div>
                                            </li>
    
                                        <?php endwhile; ?>
            </ul>
    
            <div class="homepage-btn">
                <a href="http://www.cultexposure.com/members/<?php echo $getusername; ?>/groups/"><span></span>Browse your groups</a>
            </div>
    
        </div>
    <?php } ?>
    
    
    
    

    Cheers

    Radu

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 10 posts - 1 through 10 (of 10 total)

The forum ‘Plugins questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?