1. Customize
  2. Leaderboards
  3. Add link to the author page

Add link to the author page

The following snippet shows how to add a link to the WordPress author’s page on user and avatar column.

function my_prefix_author_link_on_leaderboards( $output, $leaderboard_id, $position, $item, $column_name, $leaderboard_table ) {

    // Get the author link
    $url = get_the_author_meta( 'url', $item['user_id'] );

    return sprintf( '<a href="%s">%s</a>',
        $url,
        $output
    );
}
add_filter( 'gamipress_leaderboards_leaderboard_column_display_name', 'my_prefix_author_link_on_leaderboards', 10, 6 );
// This line makes the link work also on the user avatar column
add_filter( 'gamipress_leaderboards_leaderboard_column_avatar', 'my_prefix_author_link_on_leaderboards', 10, 6 );
Was this article helpful to you? Yes No

How can we help?