Skip to:
Content
Pages
Categories
Search
Top
Bottom

Team Roster with custom user fields


  • Cyrus180
    Participant

    @cyrus180

    Hey there,

    I want to realize a Team Roster with the help of buddypress. This Team Roster should display custom fields which are only editable by admins.

    The structure seems like:

    Group Name 1

    • Nickname: Nickname 1
    • Rank: Leader (custom field which should only be editable by admins)

    • Nickname: Nickname 2
    • Rank: Member (custom field which should only be editable by admins)

    Group Name 2

    • Nickname: Nickname 3
    • Rank: Leader (custom field which should only be editable by admins)

    • Nickname: Nickname 4
    • Rank: Member (custom field which should only be editable by admins)

    and so on.

    I figured out how to display the above structure without the custom field “Rank” with the following code:

    <?php if ( bp_has_groups() ) : ?>
            <?php while ( bp_groups() ) : bp_the_group(); ?>
      		<?php if ( bp_group_has_members( 'group_id='.bp_get_group_id().'&exclude_admins_mods=false' ) ) : ?>
            <div class="row ">
            	<div class="span12">
                	<div class="infobox1">
                    	<h3 class="m_title">
                        <?php bp_group_name() ?>
                  		</h3>
                    </div> <!-- end infobox -->
                 </div> <!-- end span -->
              </div> <!-- end row -->
              <div class="row ">
              	<?php while ( bp_group_members() ) : bp_group_the_member(); ?>
                <div class="span3">
                	<div class="team_member">
                    <a href="#" target="_blank" class="grayHover"><?php bp_group_member_avatar( 'type=full&width=75&height=75' ) ?></a>
                    <h4><?php bp_member_name(); ?></h4>
                    <h6>Clanleader</h6>
                    	<div class="details">
                    		<div class="desc">
                            <p>Max Mustermann <br />
                            Musterstadt</p>
                            </div> <!-- end description -->
                            <ul class="social-icons colored fixclear">
                            <li class="social-twitter"><a href="" target="_blank"></a></li>
                            <li class="social-facebook"><a href="" target="_blank"></a></li>
                            <li class="social-gplus"><a href="" target="_blank"></a></li>
                            <li class="social-mail"><a href="" target="_blank"></a></li>
                            </ul>
                         </div><!-- end details -->
                      </div><!-- end team_member -->
                 </div><!-- end span -->
                 <?php endwhile; ?>
                 
                 <?php else: ?>
               
                <div id="message" class="info">
                  <p>This group has no members.</p>
                </div>
               
              	<?php endif;?>
    		</div><!-- end row -->
            <?php endwhile; ?>
            <?php do_action( 'bp_after_groups_loop' ) ?>
     
    		<?php else: ?>
             
                <div id="message" class="info">
                    <p><?php _e( 'There were no groups found.', 'buddypress' ) ?></p>
                </div>
             
            <?php endif; ?>

    However I got a problem with the custom field. I can’t find a possibility to say, that only Admins can edit specific custom fields of members in the buddypress core neither with a buddypress plugin. So I thought it’s maybe possible to create a custom field for the wordpress users which can only be edited by admins and can be displayed inside the bp_group_members-loop.

    I’ve created this custom user field with the Plugin “Cimy User Extra Fields”. I know it is possible to show the custom user field with this code:

    $value = get_cimyFieldValue(user_id, field_name);
    echo cimy_uef_sanitize_content($value);

    However I can’t figure out how I can get the ID of the buddypress member into the user_id. May you can help me with that?

    Thanks for your help.

    Mats

  • The topic ‘Team Roster with custom user fields’ is closed to new replies.
Skip to toolbar