Try to add the following code to your child theme functions.php :
function bati1975_modify_birthday_to_year( $data, $id ) {
// Check if 'Birthday' key exists in the array.
if ( isset( $data[ esc_attr__( 'Birthday', 'sportspress' ) ] ) ) {
// Extract the birthday
$birthday = $data[ esc_attr__( 'Birthday', 'sportspress' ) ];
// Create a DateTime object from the string.
$date = DateTime::createFromFormat('d/m/Y', $birthday);
// Check if the date was created successfully.
if ( $date ) {
// Format the date to just get the year.
$year = $date->format('Y');
// Update the Birthday field with just the year.
$data[ esc_attr__( 'Birthday', 'sportspress' ) ] = $year;
} else {
$data[ esc_attr__( 'Birthday', 'sportspress' ) ] = 'Invalid date format';
}
}
return $data;
}
// Add the filter to modify the player details.
add_filter('sportspress_player_details', 'bati1975_modify_birthday_to_year', 30, 2);
Thanks,
Savvas