• Resolved sameeralam

    (@sameeralam)


    From the shortcodes, for ex, https://gnbl.ca/player/arsalaan-abdullah/ [player_statistics 2770] this would get me the player stats for all the games.

    Is there a way to get only specific values or fields? How or where would I have to create custom code to be able to use all this excellent data created and run my own enhanced analytics, etc.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter sameeralam

    (@sameeralam)

    In addition to this, is there a way I can post player splits ( add a new tab like how we can move stats, profile, games in a new tab on player page ), create a splits category which might show the players last 5 game averages, or last 30 day averages, their home average vs away, how they play with a certain teammate etc.

    I am happy to code all this myself of course, I just need some direction in terms of if it is possible and how I could access the data appropriately.

    Plugin Contributor Savvas

    (@savvasha)

    Hi there @sameeralam ,

    All your player stats can be called using the SP_Player Class. You can give a look at player-statistics template for example on how you can show your data.

    Thanks,
    Savvas

    Thread Starter sameeralam

    (@sameeralam)

    Thanks Savvas! Can I call this class from the custom code portion in sportspress. Or Will I have to modify the plugin code directly? (Sorry, I’m a bit new to wordpress plugins) If you can guide me a bit further, that would be appreciated.

    For ex: https://gnbl.ca/statistics-2022-2023/ , to get the top 5 player names who have the highest PPG. Is it easy to share how to get this data? If I can see this example, then I should be able to figure out the rest of the things I want to gather.

    If it is complicated to explain, then no worries.

    Plugin Contributor Savvas

    (@savvasha)

    Hi there @sameeralam ,

    To call any class you need just to… call it. No need for editing the core file or anything.

    For example at your custom code you can just use the following to get all your Player’s data for a specific League:

    //$id is your player's ID
    //$league_id is the the League ID for which you need the data.
    $player = new SP_Player( $id );
    $player_data = $player->data( $league_id );

    Thanks,
    Savvas

    Thread Starter sameeralam

    (@sameeralam)

    Thanks Savvas, so I get the class to call and I can create the code as needed to suit my requirement. But where exactly can I enter this code? Directly in a wordpress page doesnt work, neither is there an option in any of the sportspress configure pages.

    The only place I see where there is code are in the plugin files (which is why I initially was wondering if I need to create a new plugin or modify existing code).

    I hope the question is clear – please let me know where I would be able to enter my new code/ call the SP_Player class.

    Plugin Contributor Savvas

    (@savvasha)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom Code’ is closed to new replies.