Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Groups Extension API Question / Troubleshooting


  • billzy
    Participant

    @billzy

    Hi,

    I am having a bit of trouble upgrading one of my custom groups plugins to the new Groups Extension API. I am sure the answer is probably quite easy for a hardcore developer but I am facing frustrations just trying get this working. Basically I am creating an About tab for Groups. In my version I have all the fields and they are saving right, the settings page is working… It’s the display tab for public users which I am having troubles with.. To make this question easy I will use the sample (#2) provided by Buddypress http://codex.buddypress.org/developer/group-extension-api/

    All I am trying to do is display the new data I have saved in my new group tab for non admins. This is what I have tried so far with no success.

        function display() {
    
            $setting = groups_get_groupmeta( $group_id, 'group_extension_example_2_setting' );
    		
    		
            echo 'This plugin is 2x cooler!';
    		echo esc_attr( $setting );
        }

    and

        function display($group_id) {
    
            $setting = groups_get_groupmeta( $group_id, 'group_extension_example_2_setting' );
    		
    		
            echo 'This plugin is 2x cooler!';
    		echo esc_attr( $setting );
        }

    and

        function display() {
    
            $setting = groups_get_groupmeta( $group_id, $meta_key = 'group_extension_example_2_setting');
    		
    		
            echo 'This plugin is 2x cooler!';
    		echo esc_attr( $setting );
        } 

    This code works fine on the settings page but not the public nav item page
    $setting = groups_get_groupmeta( $group_id, ‘group_extension_example_2_setting’ );
    echo esc_attr( $setting );

    The rest of the code is as per the example that’s provided by buddypress but none of these work… ?

    I’ve tried a few other options but still no success. What am I doing wrong here, think I am close but just not working.

    Help would be much appreciated.

    Thanks
    Billy

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

  • Boone Gorges
    Keymaster

    @boonebgorges

    It looks like the $group_id is not passed along to the display() method in the same way as it is to the other display methods. That means you’ll need to implement your own technique to get that value. Try this:

    function display() {
        $group_id = bp_get_current_group_id();
        $setting = groups_get_groupmeta( $group_id, 'whatever' );
        var_dump( $setting );
    }

    I do think that you *ought* to be able to get the $group_id inside of display() like you can in settings_screen() etc. I’ve opened a ticket for that, which we’ll fix for 2.1. https://buddypress.trac.wordpress.org/ticket/5533#ticket


    billzy
    Participant

    @billzy

    Thanks heaps that worked a treat, much appreciated 😀

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Groups Extension API Question / Troubleshooting’ is closed to new replies.
Skip to toolbar