Buddypress Activity Plus for BuddyPress Groups - Not showing on custom template

Hi -

We're coding up a Buddypress site including the great Activity Plus plugin.

Activity Plus is showing/working fine in standard BuddyPress Group templates. However, we're coding some bespoke taxonomy pages that pull in a BuddyPress Group Feed/Activity form, and it's not showing under the form on this bespoke template.

I guess Activity Plus may need some hook that we've not included in our template, or maybe it does a check for Buddypress page? Can you help resolve?

I've included the code we're using for the form in our bespoke template below.

Cheers
Marcus

<?php if ( bp_has_groups ( 'slug=' . $issue_group_slug . '&max=1&user_id=' . $user_id ) ) : 

while ( bp_groups() ) : bp_the_group();

do_action( 'bp_before_group_activity_post_form' );

if ( is_user_logged_in() && bp_group_is_member($issue_group_id) ) : ?>

<form action="<?php bp_activity_post_form_action(); ?>" method="post" id="whats-new-form" name="whats-new-form" role="complementary">

<?php do_action( 'bp_before_activity_post_form' ); ?>

<div id="whats-new-row" class="row">

<div id="whats-new-avatar" class="col-xs-2">

<a href="<?php echo bp_loggedin_user_domain(); ?>">
<?php bp_loggedin_user_avatar( 'width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height() ); ?>
</a>

</div>

<div id="whats-new-post-box" class="col-xs-10">

<div id="whats-new-content">                                                    

<div id="whats-new-textarea">

<textarea name="whats-new" id="whats-new" cols="50" rows="4" placeholder="Add your comment"><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ); ?> <?php endif; ?></textarea>

</div>

<div id="whats-new-options">

<div id="whats-new-submit">

<input type="submit" name="aw-whats-new-submit" id="aw-whats-new-submit" value="<?php _e( 'Add Comment', 'buddypress' ); ?>" />
													<!-- Tell BuddyPress which group to post the activity to -->
<input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
<input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="<?php echo $issue_group_id; ?>" />

</div>

<?php do_action( 'bp_activity_post_form_options' ); ?>

</div><!-- #whats-new-options -->

</div><!-- #whats-new-content -->

<?php wp_nonce_field( 'post_update', '_wpnonce_post_update' ); ?>
<?php do_action( 'bp_after_activity_post_form' ); ?>

</div><!-- #whats-new-post-box -->

</div><!-- #whats-new-row -->

</form><!-- #whats-new-form -->

<?php endif; ?>

<?php do_action( 'bp_after_group_activity_post_form' ); ?>                                          

<?php endwhile; endif; ?>
  • Jack Kitterhing
    • Code Norris

    Hi there Marcus,

    Hope you're well today and thanks for your question.

    I've just been taking a look at this and it appears that this should be working, though there are some additional actions when it loads the required JS etc, that is in the file class_bpfb_binder.php from line 336.

    I'm here to help :slight_smile:

    Thanks!

    Kind Regards
    Jack.

  • marcusjwilson
    • Site Builder, Child of Zeus

    I don't think that can be the (only) issue that is stopping the Activity Plus buttons appearing, Jack -

    I tried loading those actions from lines 349-354 in class_bpfb_binder.php to the template file, and that didn't work. I also tried adding more conditionals to lines 339-347 of the plugin to load those actions on my taxonomy page:

    || (is_tax( 'toa_tax_issues' ))

    And that didn't seem to work either.

    Any other things that we should be calling on a now BuddyPress page to get Activity Plus to load?

    Thanks
    Marcus

  • Vladislav
    • Dead Eye Dev

    Hello,

    Off the top of my head, there could be several things happening - resources not being loaded is the first one. The plugin will explicitly check if we're on an activity or group activity page and load the front-end dependencies only then. To walk around this, perhaps a bit of code like this can help:

    <?php
    
    function my_check_page_reqiurement_and_lie_to_buddypress ($is, $component) {
    	if ($is || "activity" !== $component) return $is;
    	if (!is_page(1312)) return $is; // Optional: suppose we only want this to happen on page with ID=1312
    	return true;
    }
    function my_setup_activity_filter () {
    	add_filter('bp_is_current_component', 'my_check_page_reqiurement_and_lie_to_buddypress', 10, 2);
    }
    function my_teardown_activity_filter () {
    	remove_filter('bp_is_current_component', 'my_check_page_reqiurement_and_lie_to_buddypress', 10);
    }
    add_action('bpfb_init', 'my_setup_activity_filter');
    add_action('bpfb_add_cssjs_hooks', 'my_teardown_activity_filter');

    Of course, this code will check for page ID=1312, but you can substitute this line with your own custom check. Can you please give this a go and see if the plugin resources (for an example, bpfb_interface.js) are being loaded on your page? There could also be some more covert issue, like a JS conflict or error, or perhaps a missing selector, but let's first try and make sure that the dependencies are being injected on your page.

  • marcusjwilson
    • Site Builder, Child of Zeus

    Hi Vladislav

    Thanks for your suggestions, but they haven't worked, I'm afraid...

    We have tried adding those additional checks, and we've tried deleting the check for specific pages altogether. We've also tried to load the dependencies on all the pages on the website, and nothing works.

    There must be some other factor at play here. Can you think what it might be?

    Thanks
    Marcus

  • Vladislav
    • Dead Eye Dev

    Hi,

    I'm sorry for the delay, somehow I managed to miss your response. Can you please confirm if you managed to get the resources to load on your page (for an example, can you please check the "Net" tab in the Firebug console (FF), or "Network" tab in the Inspector (Chrome) for the file named bpfb_interface.js)? If so, there's a possible javascript issue of some sort. Can you also please check the output of the javascript console for any errors and/or warnings? If all of these checks come up empty and everything appears to check out but it still doesn't work, would it be at all possible for me to check the page for myself?

  • marcusjwilson
    • Site Builder, Child of Zeus

    Thanks, Vladislav - I'm just returning to this problem.

    I can confirm that "bpfb_interface.js" loads for the Groups homepage feed (i.e. /groups/changemaker-network/) but DOES NOT load for the Groups Activity page feed (/groups/changemaker-network/activity/). Therefore, Activity Plus buttons do not appear on the Activity page for Groups.

    Could you please check the page/code to help us resolve why this is the case? I can provide FTP logins, etc., as required.

    Thanks
    Marcus

  • Vladislav
    • Dead Eye Dev

    Hello,

    Thank you very much for the confirmation - in this case, it's possible something's going wrong with the page detection code I posted earlier. It did work fine for me, but it's possible there's something custom and/or site-specific on your install that prevents it from doing its job properly. Having the access to the code would help greatly in figuring out exactly what goes wrong, so if you could provide us with this info that would help a lot.

  • Jose
    • Bruno Diaz

    Hi @marcusjwilson,

    Hope you are doing great today!

    I'm just checking what is the status on this. Were you able to sort it?

    If not, can you please send me the following information via contact form:

    - In the subject field add "Attn: Jose”
    - Link back to this thread
    - Include WP admin/network access
    - Include FTP
    - Include any relevant URLS for your site

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    Thanks!
    JJ

  • Jose
    • Bruno Diaz

    Hi @marcusjwilson,

    I just fixed the issue and moved the changes to your site, so you should see it working now.

    Actually, the code provided by Vlad above works fine. You might be making some mistake with your condition.

    I change the condition to match your needs, and moved the code from the functions.php to bp-custom.php so that you can switch the theme without worrying about it.

    This is the new code in bp-custom.php:

    function toa_check_page_reqiurement_and_lie_to_buddypress ($is, $component) {
        global $bp;
        if ($is || "activity" !== $component) return $is;
        if ((defined('BP_GROUPS_SLUG') && bp_is_groups_component() && 'activity' == $bp->current_action)){
            return true;
        }
        return $is;
    }
    function toa_setup_activity_filter () {
        add_filter('bp_is_current_component', 'toa_check_page_reqiurement_and_lie_to_buddypress', 10, 2);
    }
    function toa_teardown_activity_filter () {
        remove_filter('bp_is_current_component', 'toa_check_page_reqiurement_and_lie_to_buddypress', 10);
    }
    add_action('bpfb_init', 'toa_setup_activity_filter');
    add_action('bpfb_add_cssjs_hooks', 'toa_teardown_activity_filter');

    Please dont hesitate to ask if you have further questions.

    Cheers!
    JJ

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.