Update – I tried using the link /groups/group_name/request-membership/ but that is not working
Would this code work “ to get the registration button for the group?
earlier post – Ok I am guessing that I need to pass a group object to the bp_get_group_join_button function and not the name of the group. So my next question is – is there a way to get a group object if I know a group name?
Managed to get it done finally.
`
<?php
global $wpdb;
$mgroup_name = “mygroupname”;
$myrows = $wpdb->get_results(“SELECT * FROM wp_bp_groups where slug=’$mgroup_name’;”, OBJECT);
if (count($myrows)>0) {
$group1 = $myrows[0];
$buttondata=bp_get_group_join_button($group1);
}
?>
var registrationbutton = “”;
`
false positive. The button does not seem to work on another page even though it has the right link. I am looking for the related form now
ok – so here is what was missing – there needs to be an ajax call that has to be made when the button is clicked that is what actually does the trick
`
$j(“div.signupbutton a”).live(‘click’, function() {
var gid = $j(this).parent().attr(‘id’);
gid = gid.split(‘-‘);
gid = gid[1];
var nonce = $j(this).attr(‘href’);
nonce = nonce.split(‘?_wpnonce=’);
nonce = nonce[1].split(‘&’);
nonce = nonce[0];
var thelink = $j(this);
$j.post( ajaxurl, {
action: ‘joinleave_group’,
‘cookie’: encodeURIComponent(document.cookie),
‘gid’: gid,
‘_wpnonce’: nonce
},
function(response)
{
var parentdiv = thelink.parent();
if ( !$j(‘body.directory’).length ) {
location.href = location.href;
//do stuff that you want to do on successful request send
parentdiv.fadeIn(200).html(“Thanks for signing up”);
}
else {
$j(parentdiv).fadeOut(200,
function() {
parentdiv.fadeIn(200).html(response);
}
);
}
});
return false;
});
`