BuddyDev

Search

[Resolved] Replace field_data with a SVG icon?

  • Participant
    Level: Yogi
    Posts: 1117
    calu on #43323

    Hi there, I’m using this code below, to show Xprofile Field Data in The Profile Header.

    Is it possible to replace the field_data, like’Job’ with a SVG icon?

    If yes, a code example would be much appreciated, thanks!

    Regards
    Carsten

    https://buddydev.com/support/?s=Buddypress+Show+Xprofile+Field+Data+in+The+Profile+Header&stype=all

    /**
     * Buddypress Show Xprofile Field Data in The Profile Header.
     */
    
    function yzc_add_xprofile_field_data_in_profile_header( $name ) {
    
    	$field_data = xprofile_get_field_data( 'Age', bp_displayed_user_id() );
    
    	echo "<div class='profile-job-info'>";
    
    	echo '<br/><strong>Alder:</strong> ' . $field_data;
    
    	$field_data = xprofile_get_field_data( 'From', bp_displayed_user_id() );
    	if ( ! empty( $field_data ) ) {
    		echo '  <br/> <strong>Fra:</strong> ' . $field_data;
    
    		$field_data = xprofile_get_field_data( 'Job', bp_displayed_user_id() );
    		if ( ! empty( $field_data ) ) {
    			echo '<br/><strong>Job:</strong> ' . $field_data;
    
    		}
    
    		echo '</div>';
    	}
    }
    
    add_action( 'bp_before_member_header_meta', 'yzc_add_xprofile_field_data_in_profile_header' );
  • Keymaster
    (BuddyDev Team)
    Posts: 24712
    Brajesh Singh on #43343

    Hi Carsten,
    it is doable but will be very specific to your options. you will need to put a condition and instead of $field_data you will need to switch between its values and generate the svg.

    This is neither scalable(you will need to add conditions each time you add new options) nor a good idea for a dynamic website to have it hardcoded.
    So, I will suggest avoiding it.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1117
    calu on #43347

    Hi Brajesh, thanks for the explanation and the advise.

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24712
    Brajesh Singh on #43368

    You are welcome.

The topic ‘ [Resolved] Replace field_data with a SVG icon?’ is closed to new replies.

This topic is: resolved