Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display xprofile data in Activity Stream

  • @saxisme

    Participant

    Hello,

    I’d like to display next to the member name in the activity stream, also the company field I created in the user’s extended profile.

    I cannot display the field, I can do it only if in the member page.
    I am not sure which function I should use, tried with:
    $company= xprofile_get_field_data( ‘field=company’, bp_get_member_user_id() );
    $company= xprofile_get_field_data( ‘field=company’ );
    $company= bp_get_member_profile_data( ‘field=company’, bp_get_member_user_id() );
    $company= bp_get_member_profile_data( ‘field=company’ );

    I am putting this code inside activity-loop.php before

    <?php locate_template( array( 'activity/entry.php' ), true, false ); ?>

    I appreciate if someone could point me to the right direction.
    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • @danbp

    Participant

    Hi @saxisme,

    This function will add the company name under each user avatar, on every activity screen (swa, profile, friends…)
    To do so, you have to add a do_action to the template. In your case, add it into (child theme)/buddypress/activity/entry.php, before the closing tag of the div containing the avatar (around line 24)

    The snippet goes into theme’s functions.php or bp-custom.php

    function saxisme() {
    	$user_id = bp_get_activity_user_id();
    	$company = xprofile_get_field_data('42', $user_id); // field ID or name
    		
    	echo '<div class="authorinfo">'. $company . '</div>';
    	
    }
    
    add_action( 'showsaxisme', 'saxisme' );

    You add this to entry.php
    <?php do_action( 'showsaxisme'); ?>

    @saxisme

    Participant

    @danbp, thank you very much!

    Surely this leads me to the right direction – I am now using this function in other parts of the site.

    What I am struggling to to is something slightly different: put the xprofile field (Company) after the user name, in the same user profile link.

    Ex: <a original-link-to-member-profile-page>saxisme - company xyz</a> posted a content in the group ABC.

    I am starting to play with what @danpdfr is posting here

    Thank you in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display xprofile data in Activity Stream’ is closed to new replies.
Skip to toolbar