Reply To: Changing Avatar based on field data
@prashantvatsh Sorry to bother you, but I tried the following solution, and it is still not working:
First, I added the following code to my bp-custom.php file:
<?php
//The following creates avatar class in activity stream
//based on x-profile field data
function buddydev_create_avatar_class_based_on_field_data() {
$user_id = bp_get_activity_user_id();
$title = xprofile_get_field_data('25', $user_id); // field ID or name
$title = strtolower( $title );
$class = $title.'avatar';
echo $class;
}
add_action( 'create_activity_avatar_class_based_on_field_data', 'buddydev_create_avatar_class_based_on_field_data', 10, 1 );
?>
Then, I added the following as a class inside the div tag for activity avatar in my buddypress/bp-templates/bp-legacy/buddypress/activity/entry.php file:
<?php do_action( 'create_activity_avatar_class_based_on_field_data'); ?>
Yet still it is not working. Did I put the do_action in the wrong file?