Replicating ’Join Group’ link
-
I’m working on a website called ‘Adopt an MP’ in which people can register as a ‘tracker’ (member) and choose to ‘track’ a constituency by joining a group: http://adoptanmp.ukycc.org/
Using the API from http://www.theyworkforyou.com/api/, I’ve created a plugin which pulls a member’s postcode from an xtended profile field, runs it through the API, and constructs a link to join the corresponding Buddypress group.
function getConstituency() {
// Include the API binding
require_once 'twfyapi.php';
// Set up a new instance of the API binding
$twfyapi = new TWFYAPI('
API KEY
');
// Get the Constituency Name via getConstituency and user's profile field data
$constituency = $twfyapi->query('getConstituency', array('output' => 'php', 'postcode' => bp_get_profile_field_data( 'field=Post Code&user_id=' . bp_get_member_user_id() )));
//Unserialize data returned
$constituency = unserialize ( $constituency );
//Get Constituency Name
$constituency = $constituency["name"];
//convert it into a string which (hopefully) corresponds to slug of a Buddypress group
$constituencyURL = strtolower($constituency);
$constituencyURL = preg_replace('/s/','-',$constituencyURL);
//Build the URL
echo '';
};
It seems to be constructing the link url correctly (complete with wp_nonce etc), but when clicked on, it doesn’t seem to work. However, if I paste the url into my browser address bar and run it that way, it does. Anybody know what’s going on here? Thanks!
- The topic ‘Replicating ’Join Group’ link’ is closed to new replies.