Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display Avatar Changes in Activity Feed


  • Kokiri
    Participant

    @kokiri

    Hello BuddyPress Support Team / Community,

    I hope this message finds you well. I am writing to request a feature enhancement for our BuddyPress community. We would love to see an option to automatically display when a user uploads or updates their avatar in the activity feed. This feature would significantly enhance user engagement by keeping the community informed of profile updates and encouraging interactions.
    Benefits:

    Increased Visibility: Members can immediately see when someone updates their avatar, promoting profile visits and interactions.
    Enhanced Engagement: Users are more likely to comment or react to avatar changes, fostering a sense of community.
    Streamlined User Experience: Automated updates in the activity feed ensure that members do not miss out on important profile changes.

    Suggested Implementation:

    Avatar Update Trigger: When a user uploads or updates their avatar, a trigger should generate a new activity entry.
    Activity Message: The activity entry could display a message like “User [Username] has updated their avatar.”
    Integration with Existing Feed: The new activity entry should seamlessly integrate with the existing activity feed, appearing in chronological order.

    Customization Options:

    Privacy Settings: Allow users to opt-out of broadcasting their avatar changes if they prefer privacy.
    Activity Message Customization: Option for users to add a custom message along with their avatar update notification.

    We believe this feature would greatly benefit our community and enhance user experience. Thank you for considering our request. We look forward to your response and any potential updates on this feature. We did find a way to block certain activity types from showing up in the activity feed – however we’re looking for a way to add this particular type in our feeds.

    Best regards,

Viewing 5 replies - 1 through 5 (of 5 total)

  • Kokiri
    Participant

    @kokiri

    I tried writing this code however no luck.

    <?php
    // Add action to show new avatar in activity stream
    function custom_bp_avatar_activity($user_id, $args) {
    // Get the user data
    $user = get_userdata($user_id);
    $user_link = bp_core_get_userlink($user_id);

    // Create the activity entry
    bp_activity_add(array(
    ‘user_id’ => $user_id,
    ‘action’ => sprintf(__(‘%s has updated their avatar.’, ‘buddypress’), $user_link),
    ‘component’ => ‘profile’,
    ‘type’ => ‘new_avatar’,
    ‘item_id’ => $user_id,
    ));
    }
    add_action(‘xprofile_avatar_uploaded’, ‘custom_bp_avatar_activity’, 10, 2);

    // Add action to show profile update in activity stream
    function custom_bp_profile_update_activity($user_id, $posted_field_ids, $errors, $old_values, $new_values) {
    // Get the user data
    $user = get_userdata($user_id);
    $user_link = bp_core_get_userlink($user_id);

    // Create the activity entry
    bp_activity_add(array(
    ‘user_id’ => $user_id,
    ‘action’ => sprintf(__(‘%s has updated their profile.’, ‘buddypress’), $user_link),
    ‘component’ => ‘profile’,
    ‘type’ => ‘updated_profile’,
    ‘item_id’ => $user_id,
    ));
    }
    add_action(‘xprofile_updated_profile’, ‘custom_bp_profile_update_activity’, 10, 5);
    ?>


    Abhishek Saini
    Participant

    @abhishek6394

    Buddypress by default provide the creating activity on profile uploads.

    https://prnt.sc/qg-NDzJP9nll

    If you want to add your custom activity as you have given in your code snippet you can use it like this because hook is deprecated.

    // Add action to show new avatar in activity stream
    function custom_bp_avatar_activity($user_id, $args) {
    // Get the user data
    $user = get_userdata($user_id);
    $user_link = bp_core_get_userlink($user_id);

    // Create the activity entry
    bp_activity_add(array(
    ‘user_id’ => $user_id,
    ‘action’ => sprintf(__(‘ % s has updated their avatar newly.’, ‘buddypress’), $user_link),
    ‘component’ => ‘profile’,
    ‘type’ => ‘new_avatar’,
    ‘item_id’ => $user_id,
    ));
    }
    add_action(‘bp_members_avatar_uploaded’, ‘custom_bp_avatar_activity’, 10, 2);

    https://prnt.sc/DHAc_eWrYJY7


    Kokiri
    Participant

    @kokiri

    @abhishek6394

    Unfortunately that code didn’t work for a code snippet.


    Kokiri
    Participant

    @kokiri

    I wasn’t quick enough to make an edit on the post above ^
    However the error says:

    Snippet automatically deactivated due to an error on line 3:

    Cannot redeclare function custom_bp_avatar_activity.


    Abhishek Saini
    Participant

    @abhishek6394

    @Kokiri
    Please change this function name “custom_bp_avatar_activity” and keep it unique and please remember this also that this will create a new activity So, you will get two activity for single profile uploads.

    // Add action to show new avatar in activity stream
    function bp_generate_custom_avatar_activity($user_id, $args) {
    // Get the user data
    $user = get_userdata($user_id);
    $user_link = bp_core_get_userlink($user_id);
    
    // Create the activity entry
    bp_activity_add(array(
    ‘user_id’ => $user_id,
    ‘action’ => sprintf(__(‘ % s has updated their avatar newly.’, ‘buddypress’), $user_link),
    ‘component’ => ‘profile’,
    ‘type’ => ‘new_avatar’,
    ‘item_id’ => $user_id,
    ));
    }
    add_action(‘bp_members_avatar_uploaded’, ‘bp_generate_custom_avatar_activity’, 10, 2);
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar