Skip to:
Content
Pages
Categories
Search
Top
Bottom

Can I make this Profile data any better?


  • Shmoo
    Participant

    @macpresss

    I don’t have super advanced PHP skills so I made this as a start to show off only 3 profile fields (will be svg icons later) ..when their set of course.

    
    <?php
    	$twitter = bp_get_member_profile_data( 'field=Twitter', bp_get_member_user_id() );
    	$instagram = bp_get_member_profile_data( 'field=Instagram', bp_get_member_user_id() );
    	$website = bp_get_member_profile_data( 'field=Website', bp_get_member_user_id() );
    
    	if ( isset( $twitter, $instagram, $website ) ) {
    
    		echo '<div class="test">';
    
    			if ( isset( $twitter ) ) {
    				echo '<span>'. $twitter .'</span><br>';
    			}
    			if ( isset( $instagram ) ) {
    				echo '<span>'. $instagram .'</span><br>';
    			}
    			if ( isset( $website ) ) {
    				echo '<span>'. $website .'</span><br>';
    			}
    
    		echo '</div>';
    	}
    ?>
    

    I have this feeling, this can be made better or nicer within some sort of loop instead of all those IF statements.

    Usually I use Advanced Custom Fields Pro for those kinda of things because of their detailed Documentation and examples but I thought it would be overkill to use ACF only for 3 simple fields while BuddyPress has this inside the core.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar