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
Carstenhttps://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' );
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
The topic ‘ [Resolved] Replace field_data with a SVG icon?’ is closed to new replies.