Support » Plugin: Football Pool » Display First and Last name in Charts

  • Resolved Joepiooo



    I’m using a registration form where users also have to add there first and lastname.

    Instead of the username I want to display the first and lastname of a user everywhere. I’m almost done changing it everywhere but I cant manage to change it in the charts.

    I’ve done it like this:

    // chart 2: scoreverloop
    					if ( count( $users ) >= 1 ) {
    						$output .= '<br class="clear" />';
    						$raw_data = $chart_data->score_per_match_line_chart_data( $users, $ranking );
    						if ( count( $raw_data ) > 0 ) {
    							$chart = new Football_Pool_Chart( 'chart2', 'line', 720, 500 );
    							$chart->data = $chart_data->score_per_match_line_series( $raw_data );
    							$chart->title = __( 'points scored', FOOTBALLPOOL_TEXT_DOMAIN );
    							$txt = __( 'points', FOOTBALLPOOL_TEXT_DOMAIN );
    							$voornaam = get_user_meta($user, "voornaam", true);
    							$achternaam = get_user_meta($user, "achternaam", true);
    							$chart->options[] = "tooltip: {
    													shared: true, crosshairs: true,
    													formatter: function() {
    														s = '<b>' + categories[this.x] + '</b><br/>';
    														jQuery.each( this.points, function( i, point ) {
    															s += '<b style=\"color:' + point.series.color + '\">'
    																+ + ' {$voornaam}{$achternaam}</b>: '
    																+ point.y + ' {$txt}<br>';
    														} );
    														return s;
    							$chart->JS_options[] = 'options.xAxis.labels.enabled = false';
    							$chart->JS_options[] = 'options.yAxis.min = -1';
    							$chart->JS_options[] = 'options.yAxis.showFirstLabel = false';
    							$output .= $chart->draw();

    It is showing the first and last name of 1 single user but not of all the users. Somehow he is just getting one single first and lastname.

    Is there a way I can make this work?

    Thanks in advance:)

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author AntoineH


    You will have to change the data that is the source for the chart ($raw_data). That array contains the user names for all users.

    See file classes/class-football-pool-chart-data.php, function per_match_line_chart_data()

    Hi Antoine,

    Thanks for the fast reply.

    I found it but how can I change this array and provide it with get_user_meta data?

    foreach ( $rows as $row ) {
    				$voornaam = get_user_meta($row['user_id'], "voornaam", true);
    				$data[] = array(
    								'match'    => $row['score_order'],
    								'type'     => $row['type'],
    								'value'    => $row[$history_data_to_plot],
    								'user_name' => $voornaam

    I tried this but that is not working. I get only one game and the name is “Series 1”.

    Do you know how to fix this:)?

    Plugin Author AntoineH


    I’ll look into it tonight.

    Plugin Author AntoineH


    It looks like you didn’t include the user_id in the SQL query so your function is always returning an empty string for the $voornaam variable.

    $sql = $wpdb->prepare( "SELECT h.source_id, h.{$history_data_to_plot}, u.ID AS user_id, u.display_name, h.type

    Plugin Author AntoineH


    P.s. I decided to change the way user names are displayed on the frontend for version 2.4.0. All is now handled by one function where the name can be changed with a filter.

    Hi Antoine,

    Thanks for your answer! Is working great now:)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Display First and Last name in Charts’ is closed to new replies.