Link Top Participants to Individual TeamRaiser pages from Wordpress Site

Options

Hello,

looking for some assistance…I have a page set within a wordpress site that is pulling in the Top Participants. Of which, is working great! But now, I am looking to link each participant to their corresponding individual TeamRaiser pages. Here is the code I currently have set up…


<html>
<head></head>
<body>

<div id="top-fundraisers"> />

<script>

// Set up our HTTP request
var xhr = new XMLHttpRequest();

// Setup our listener to process completed requests
xhr.onload = function () {

// Process our return data
if (xhr.status >= 200 && xhr.status < 300) {
// What do when the request is successful
console.log('success!', xhr);
var container = document.getElementById("top-fundraisers");

var response = JSON.parse(xhr.responseText);
for (var count in response.getTopParticipantsDataResponse.teamraiserData) {
var participant = response.getTopParticipantsDataResponse.teamraiserData[count];
container.innerHTML += participant.name;
container.innerHTML += " - ";
container.innerHTML += participant.total;
container.innerHTML += "<br/>";
}

} else {
// What do when the request fails
console.log('The request failed!');
}

// Code that should run regardless of the request status
console.log('This always runs...');
};

// Create and send a request

var URL = "https://[CODE]/site/CRTeamraiserAPI?";
URL += "method=getTopParticipantsData";
URL += "&api_key=API KEY";
URL += "&v=1.0";
URL += "&response_format=json";
URL += "&fr_id=1740";

xhr.open('POST', URL);
xhr.send();

</script>

</body>
</html>

Assuming, the current method “TopParticipantsData” offers the requested ability.

Thank you in advanced!!

Tagged:

Comments

  • Hi, Michael!

    The getTopParticipantsData call will get you what you need but you'll need to form the Personal Page link yourself. In your example the px or participant ID is going to be called with participant.id from the API call.

    So in your loop, you'd need to create the anchor tag and for the HREF you would form:

    https://YOURLUMINATESITEURL/TR?fr_id=1740&px="+participant.id+"&pg=personal

    You're likely going to be better off creating actual containers (DIV, P or otherwise) with class names for each result. I think it would just save you a headache down the road versus depending on BR tags between each. Personal preference but certainly not required.

    Hopefully this helps but let me know if I misunderstood the question.

Categories