Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#4940 closed defect (bug) (no action required)

bp_is_current_action() not working for groups if using page name other than 'groups'

Reported by: rogercoathup's profile rogercoathup Owned by:
Milestone: Priority: normal
Severity: major Version: 1.7
Component: Core Keywords: reporter-feedback
Cc:

Description

bp_is_current_action() isn't working when the Groups slug / page name is changed to something other than the default 'groups'.

i.e. with the page name for Groups set to 'Groups', the function works correctly -

bp_is_current_action('follow') correctly returns true for the URL: http://testing.mysite.com/groups/test-group/follow

But, with the page name / slug for Groups set to 'xyz', it doesn't work correctly -

bp_is_current_action('follow') incorrectly returns false for the URL: http://testing.mysite.com/xyz/test-group/follow

Notes:

  1. This problem only seems to have arisen in the late beta / full release of BP1.7, and I believe was working correctly previously
  2. bp_is_groups_component() still works correctly with the slug / page name at both default of 'groups' and when set to 'xyz'

Change History (7)

#1 @boonebgorges
11 years ago

  • Keywords reporter-feedback added

I can't reproduce the issue.

Can you be more specific about the following:
1) How are you creating the 'follow' tab? Is it a publicly available plugin? Does it use BP_Group_Extension?
2) Where are you putting the bp_is_current_action() check? In a template? If it's in a function, when is the function being run (what is it hooked to)?

#2 @r-a-y
11 years ago

Are you using BP Follow Me?
https://wordpress.org/extend/plugins/buddypress-follow-me/

If so, try using BP Follow instead and see if you run into the same problem:
https://wordpress.org/extend/plugins/buddypress-followers/

BP Follow Me is a fork that was created when BP Follow wasn't being updated.

#3 @rogercoathup
11 years ago

@Ray - No, follow is a piece of custom code - not related to those plugins (which I think are related to following members, not groups)

The test is in an action hooked on 'bp_actions':

function ar_firms_follow_firm_action() {

global $bp;?>


<script type="text/javascript">

console.log( <?php echo $bp->current_component ?> );
console.log( <?php echo $bp->current_action ?> );


</script>


<?php

if ( !bp_is_single_item()
!bp_is_groups_component() !bp_is_current_action( 'follow' ) )

return false;

Nonce check
if ( !check_admin_referer( 'firms_follow_firm' ) )

return false;

Skip if already following
if ( !ar_firms_is_following ( $bp->groups->current_group->id, bp_loggedin_user_id() ) ) {

ar_firms_follow_firm( $bp->groups->current_group->id, bp_loggedin_user_id() );


bp_core_add_message( ( 'You are now following this firm', 'architype' ) );

bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );

}

bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );

}

add_action( 'bp_actions', 'ar_firms_follow_firm_action' );

As mentioned in OP -- this works fine if the Groups page is set to 'Groups', but not if set to something else like 'Firms'. Component part is correct in both cases, but the action part isn't set when the page is different. i.e.:

http://mysite.com/groups/test-group/follow - the action hook works with both component and action set correctly
http://mysite.com/firms/test-group/follow - the action hook doesn't work - the component is set correctly, but not the action

@Boone - there's no new tabs for the follow, just some actions and related functions / dialogs. Yes, it uses Group_Extension for setting up meta and some other tabs.

Version 0, edited 11 years ago by rogercoathup (next)

#4 @boonebgorges
11 years ago

Thanks for the additional details, rogercoathup. But, as I mentioned above, changing the 'Groups' page name is working fine for me with every other group plugin I've tried, so this problem must be due to the specifics of how you are adding the 'follow' subpage. Are you using any code to add a 'follow' action, or is it just something that BP is autodetecting in the URL?

In any case, I can't reproduce using your code. I put the following in my bp-custom.php (note I had to add quote marks to the JS to make it work):

function ar_firms_follow_firm_action() {
    global $bp; ?>
    
    <script type="text/javascript">
        console.log( '<?php echo $bp->current_component ?>' );
        console.log( '<?php echo $bp->current_action ?>' );
    </script>

    <?php
}
add_action( 'bp_actions', 'ar_firms_follow_firm_action' );

As intended, 'groups' and 'follow' are getting logged to the console when I visit groups/group-name/follow.

If there's any code you're using that's relevant to the adding of the 'follow' action, please share it here. Otherwise, you might consider testing on a fresh installation of BP, to see if you're experiencing conflicts with your plugins/theme.

#5 @rogercoathup
11 years ago

Hi Boone -- thanks for your time on this.

The code has started working again on our site as well -- can only assume we had a plugin or similar installed that was causing a clash.

Unfortunately, I don't know which or whether that was the cause - multi developers, plugin upgrades, etc during last few days.

Thanks again, Roger

#6 @rogercoathup
11 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#7 @boonebgorges
11 years ago

  • Milestone Awaiting Review deleted

Cool - very glad to hear it's working. If you figure out what the problem was, please post it here for posterity (and in case there's something BP could do better to help).

Note: See TracTickets for help on using tickets.