Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP Group Extension API


  • sbdm05
    Participant

    @sbdm05

    Hello there!
    Iam really new at this exercise, so iam really sorry if i ask some very basic questions! πŸ˜‰

    Here is what I try to achieve:
    1) new step in creating a group, so there is ‘town’ for each group.
    2) Make this new field searcheable

    OK, i copy paste the example the second example i found here:

    Group Extension API


    It works: it creates a new tab ‘Town’ in the creation process.
    BUT, going front-end Group> Town, it displays the text ‘great plugin’. I dont know how to ‘call’ the correct data.

    2) Well, at this point, i would like to know how to add a field in the groups directory page.

    Many Many thanks for your reply!

    So

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

  • shanebp
    Moderator

    @shanebp

    Try:

    function display() {
         $town = groups_get_groupmeta( $group_id, 'town' );
         echo esc_attr( $town );
    }

    sbdm05
    Participant

    @sbdm05

    First, thank you very much for you quick reply!

    I’ve been trying to implement that but nothing happens.

    Could you please have a look at the code as I am really a beginner at this! Thank you so much!

    [edited – Please Use the ‘code’ button when including code.
    Or even better, use gist or pastebin and just share the link ]

    if ( class_exists( 'BP_Group_Extension' ) ) :
    	
    	class Group_Extension_Ville extends BP_Group_Extension {
    		
    		function __construct() {
    			$args = array(
    			'slug' => 'group-extension-ville',
    			'name' => 'ville',
    			);
    			parent::init( $args );
    		}
    		
    		
    		function display() {
    			$group_extension_ville = groups_get_groupmeta( $group_id, 'group_extension_ville' );
    			echo esc_attr( $group_extension_ville );
    		}
    		
    		
    		function settings_screen( $group_id ) {
    			$setting = groups_get_groupmeta( $group_id, 'group_extension_ville' );
    		
    		?>
    			Save your plugin setting here: <input type=”text” name='group_extension_ville_setting' value='<?php echo esc_attr( $setting ) ?>' />
    		<?php
    		}
    		
    		
    		function settings_screen_save( $group_id ) {
    			$setting = '';
    			
    			if ( isset( $_POST['group_extension_ville_setting'] ) ) {
    				$setting = $_POST['group_extension_ville_setting'];
    			}
    			
    			groups_update_groupmeta( $group_id, 'group_extension_ville_setting', $setting );
    		}
    	}
    	bp_register_group_extension( 'Group_Extension_Ville' );
    
    endif; // if ( class_exists( 'BP_Group_Extension' ) )

    shanebp
    Moderator

    @shanebp

    Please note the edits made above.

    You’re saving a groupmeta field called ‘group_extension_ville_setting’
    but in display() and settings_screen() you’re asking for a groupmeta field called ‘group_extension_ville’ – so of course it will not work.


    sbdm05
    Participant

    @sbdm05

    Hey Shane!
    Thank you for your help.

    So here is the new code, but still nothing appears : again iam really sorry to ask you such basic things! really appreciate your help on this!


    sbdm05
    Participant

    @sbdm05

    Hey,
    Actually, it appears for the admin only under groupname/admin/edit-details/ville.

    But for regular users and admin, the tab ‘ville’, next to ‘admin’ is empty.

    Hope this is not too much confusing!

    So


    shanebp
    Moderator

    @shanebp

    Where are you running your code?
    Try it in a plugin or in bp-custom.php

    Try this code.


    sbdm05
    Participant

    @sbdm05

    Works perfectly! thanks you so much!!!! πŸ˜‰ thank you for your time and patience!!!
    Still need to figure out how to use that in the search form though, if you have any idea…;-)

    (btw, i was putting the code in mytheme-child>functions.php)

    Cheers, So


    sbdm05
    Participant

    @sbdm05

    Hey Shane! Right now, the city is not ‘clickable’ in the group profile.
    It would be great if it could be just like a category. (what i would like to achieve is a drop down menu with a limited choice of towns).
    If i click, i would have all the groups that have the same town.
    Do you think that is possible?
    Hope I am not pushing too far!

    So

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘BP Group Extension API’ is closed to new replies.
Skip to toolbar