Try:
function display() {
$town = groups_get_groupmeta( $group_id, 'town' );
echo esc_attr( $town );
}
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' ) )
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.
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!
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
Where are you running your code?
Try it in a plugin or in bp-custom.php
Try this code.
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
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