Skip to:

Show text from API in users profile

  • MilliR


    Hi there. Sorry if this is in the wrong section or the topic title didn’t make any sense as I don’t really know how to phrase my question.

    Well, my problem is this. I have an API that shows users League of Legends rank if summoners name is provided. I have successfully created a function to do this. Here are the steps I took to achieve this.
    – Custom profile field asking Summoner Name.
    – in a custom function, using bp_get_profile_field_data( ‘field=Summoner Name’ ), I extract the summoner name and pass it on to the api to get the players rank.
    – returns the rank.

    So far, this function is working fine. What I want to do is this:
    – I have a field group called LoL Info.
    – I want the user to just enter their summoner’s name in a text field.
    – By using the mentioned function, I will pull the users rank, summoner icon, team rank etc and show it in the profile.


    LoL Info
    Summoner name: WildTurtle
    Solo Rank: Platinum III
    Team Rank: Gold II
    Summoner icon: … summoner icon image in here …

    How do I go about doing this? Here’s the function I am using:

    function my_summoner_rank() {
    	$playername = bp_get_profile_field_data( 'field=Summoner Name' );
    	$request = "{$playername}";
    	$response = file_get_contents($request);
    	$results = json_decode($response, TRUE);
    	$division = $results['results']['rank-stat'];
    	foreach($division as $key => $value) {
    		$thesolorank = $value['solo-rank'];
    		$theteamrank = $value['team-rank'];//will use this later
    //get the icon too....
    	return $thesolorank;
  • The topic ‘Show text from API in users profile’ is closed to new replies.
Skip to toolbar