new tab and bo activity stream

This topic contains 12 replies, has 2 voices, and was last updated by  Paolo 8 years, 11 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #37436

    urbanfix
    Expired Member
    Post count: 310

    I have created a new tab on the listings detail page and would like to display the authors activity stream on it, would this be hard to do? Can anybody point me in the right direction?
    Would i simply call in the activity loop within the functions.php file?
    Thanks

    #37438

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    yes using the user_id as filter.

    To get the author ID of a listing, you can use get_the_author_meta

    Here you can find examples: https://codex.buddypress.org/developer/loops-reference/the-activity-stream-loop/#filtering-examples

    Thanks

    #37440

    urbanfix
    Expired Member
    Post count: 310

    Thanks paolo,
    just to give me a kick in the right direction can you explain where i would put the following code.

    This is my add new tab in functions.php

    
    
    <?php add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend') ;
    
    function geodir_detail_page_tab_list_extend($tab_array)
    {
     	$tab_array['my_new_tab'] = array( 
    										'heading_text' =>  __('New Tab',GEODIRECTORY_TEXTDOMAIN),
    										'is_active_tab' => false,
    										'is_display' =>  apply_filters('geodir_detail_page_tab_is_display', true, 'my_new_tab'),
    										'tab_content' => ''
    									);
    	return $tab_array ;
    }
    add_action('geodir_after_tab_content' ,'geodir_my_new_tab_content');
    function geodir_my_new_tab_content($tab_index)
    {
    	if($tab_index =='my_new_tab')
    	{
    		echo "Hello world!!";
    	}
    }
    ?>

    where would i add the following basic activity loop?

    
    
    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : ?>
        <?php while ( bp_activities() ) : bp_the_activity(); ?>
     
            <?php locate_template( array( 'activity/entry.php' ), true, false ); ?>
     
        <?php endwhile; ?>
    <?php endif; ?>

    Thanks

    #37442

    Paolo
    Site Admin
    Post count: 31206

    Something like that.

    
    
    if($tab_index =='my_new_tab')
    	{?>
    		
    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : ?>
        <?php while ( bp_activities() ) : bp_the_activity(); ?>
     
            <?php locate_template( array( 'activity/entry.php' ), true, false ); ?>
     
        <?php endwhile; ?>
    <?php endif; } ?>

    Thanks

    #37455

    urbanfix
    Expired Member
    Post count: 310

    I am really stuck with this and i just can’t figure it out,
    I dont know how to get the php to display on the tab its self, i just keep getting errors, I even tried to add a simple bit of code to get the user id and i got an error!
    I have wasted far to much time on this, say i wanted to add this code the my new tab;

    
    
    <?php function get_user(){
    
    global $bp;
    $username = $bp->loggedin_user->id;
    echo $username;
    }
    
    get_user(); ?>

    how would i add it to the new tab?

    #37490

    urbanfix
    Expired Member
    Post count: 310

    Any help guys…?

    #37498

    Paolo
    Site Admin
    Post count: 31206

    Hi Urbanfix,

    to do that, you should ask for support on the buddypress forum, don’t you think?

    The function you need is not part of our plugin and we don’t support 3rd party plugins.

    Our responsability is to tell you how to create the new GD tab and how to put new content in it.

    To write a function for another plugin to actually create the content is part of your job.

    Thanks

    #37500

    urbanfix
    Expired Member
    Post count: 310

    okay fair enough,
    In that case could you tell me how to add this

    
    
    <?php function get_user(){
    
    global $bp;
    $username = $bp->loggedin_user->id;
    echo $username;
    }
    
    get_user(); ?>

    into my new tab?

    #37503

    Paolo
    Site Admin
    Post count: 31206

    This should work:

    
    
    add_action('geodir_after_tab_content' ,'geodir_my_new_tab_content');
    function geodir_my_new_tab_content($tab_index)
    {
    	if($tab_index =='my_new_tab')
    	{
    	global $bp;
            $username = $bp->loggedin_user->id;
            echo $username;
    	}
    }

    Let us know,

    Thx

    #37787

    urbanfix
    Expired Member
    Post count: 310

    Could i use a shortcode on the tab?
    I am using this plugin; http://buddydev.com/plugins/bp-activity-shortcode/
    Can i use the shortcode to add it to the tab i created?
    Thanks

    #37795

    Paolo
    Site Admin
    Post count: 31206

    Yes that should be possible using the do_shortcode wordpress function: https://codex.wordpress.org/Function_Reference/do_shortcode

    Let us know how you went!

    Thanks

    #58161

    urbanfix
    Expired Member
    Post count: 310

    This was successful,
    Thankyou,
    UF!

    #58164

    Paolo
    Site Admin
    Post count: 31206

    You are welcome. 🙂

Viewing 13 posts - 1 through 13 (of 13 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount