Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • tdakanalis
    Participant

    @tdakanalis

    It works like a charm!


    tdakanalis
    Participant

    @tdakanalis

    Hi,

    I’ve developed a plugin that extends the BP_Group_Extension class to enhance BuddyPress Groups’ functionality. Inside the class constructor, I aim to access the settings of the respective group to verify if the extension has been activated through that group’s settings.

    Before BuddyPress version 12, I could simply access the $bp->groups->current_group->id to retrieve the current group’s ID. However, after upgrading to version 12, accessing $bp->groups->current_group returns just 0. How can I now retrieve the group ID from within the constructor in version 12? Here is a sample code demonstrating what I am trying to do:

    
    class MyExtension extends BP_Group_Extension {
      function __construct() {
            global $bp;
            $group_id = $bp->groups->current_group->id;
      }
    }
    
    function register_group_extension() {
        bp_register_group_extension( 'MyExtension' );
    }
    
    add_action( 'bp_init', 'register_group_extension' );
    
Viewing 2 replies - 1 through 2 (of 2 total)
Skip to toolbar