Last active
June 13, 2022 10:21
-
-
Save KaineLabs/a84ebc08a3024a9bb67399d1d4f770b5 to your computer and use it in GitHub Desktop.
Add Profile Header Custom Fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add Profile Header Custom Fields. | |
*/ | |
function yzc_add_profile_header_custom_meta_fields() { | |
// Add Field Names or Ids. | |
$fields = array( | |
array( | |
'field_id_or_name' => 'age', | |
'icon' => 'fas fa-birthday-cake', | |
), | |
array( | |
'field_id_or_name' => 'last name', | |
'icon' => 'fas fa-mask', | |
) | |
); | |
foreach ( $fields as $field ) { | |
$value = xprofile_get_field_data( $field['field_id_or_name'], bp_displayed_user_id() ); | |
if ( empty( $value ) ) { | |
continue; | |
} | |
echo '<li><i class="' . $field['icon'] . '" aria-hidden="true"></i><span>' . $value . '</span></li>'; | |
} | |
} | |
add_action( 'youzify_get_profile_header_user_meta', 'yzc_add_profile_header_custom_meta_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment