learndash_csv_object

apply_filters( 'learndash_csv_object',  lmsParseCSV $csv,  string $context )

Filters csv object.


Description #


Parameters #

$csv

(lmsParseCSV) CSV object.

$context

(string) The context of the csv object.


Source #

File: includes/class-ld-lms.php


Examples #

 <?php
/**
 * Example usage for learndash_csv_object filter.
 */
add_filter(
	'learndash_csv_object',
	function ( $csv_object, $context = '' ) {

		// Example 1: Set the field delmieter from the default comma ',' to semi-colon ';'
		// This is the default needed for MS Excel in EU.
		$csv_object->delimiter = ';';

		// Example 2: Change the encoding to something other than 'ISO-8859-1'.
		// This takes two parameters 1) inbound and 2) output.
		// Also adding '//IGNORE' aftee the encoding type can prevent errors in the conversion which might cause errors.
		$csv_object->encoding( 'utf-8//IGNORE', 'utf-8//IGNORE' );

		// Return the CSV object
		return $csv_object;
	},
	10,
	2
);