Actions/Filters for Developers

Tin Canny for WordPress provides the hooks below for advanced developers to use when developing custom functionality that integrates with the plugin. No support is provided for the use of these filters.

/**
 * Minimum capability required to view Tin Canny reports. Default: tincanny_reporting
 */
add_filter( 'uo_tincanny_reporting_capability', function ( $capability ) {
	$capability = 'edit_pages';
	return $capability;
} );
/**
 * Minimum capability required to retrieve Tin Can / xAPI report data via REST. Default: manage_options
 */
add_filter( 'tincanny_can_get_data', function ( $capability ) {
	$capability = 'edit_pages';
	return $capability;
} );
/**
 * Minimum capability required to open Manage Content. Default: manage_options
 */
add_filter( 'tc_manage_content_cap', function ( $capability ) {
	$capability = 'edit_pages';
	return $capability;
} );
/**
 * Minimum capability required to upload modules. Default: manage_options
 */
add_filter( 'tincanny_can_upload_content', function ( $capability ) {
	$capability = 'edit_pages';
	return $capability;
} );
/**
 * Whether the current user may view front-end report shortcodes.
 */
add_filter( 'uo_tincanny_reporting_access_check', function ( $allowed ) {
	$allowed = current_user_can( 'edit_pages' );
	return $allowed;
} );
/**
 * Whether to process an incoming LRS request. Default: true
 */
add_filter( 'tincanny_process_content', function ( $process, $array ) {
	$process = true;
	return $process;
}, 10, 2 );
/**
 * Whether to write a statement to the reporting table. Default: true
 */
add_filter( 'tincanny_module_allow_db_capture', function ( $allow, $report_data ) {
	if ( ! empty( $report_data['verb'] ) && 'experienced' === $report_data['verb'] ) {
		$allow = false;
	}
	return $allow;
}, 10, 2 );
/**
 * Learner name passed into a module.
 */
add_filter( 'uo_tincanny_actor_name', function ( $user_name, $user ) {
	$user_name = 'Learner #' . $user->ID;
	return $user_name;
}, 10, 2 );
/**
 * Learner email passed into a module.
 */
add_filter( 'uo_tincanny_actor_mbox', function ( $user_email, $user ) {
	$user_email = $user->user_email;
	return $user_email;
}, 10, 2 );
/**
 * Fires after a statement is written to the reporting table.
 */
add_action( 'tincanny_module_statement_recorded', function ( $report_data ) {
} );
/**
 * Fires when a module URL matches /uncanny-snc-wp/{id}/.
 */
add_action( 'tincanny_module_completed', function ( $module_id, $user_id, $verb ) {
	update_user_meta( $user_id, 'tincanny_last_module', $module_id );
}, 10, 3 );
/**
 * Fires when a module result is processed.
 */
add_action( 'tincanny_module_result_processed', function ( $module_id, $user_id, $result ) {
}, 10, 3 );
/**
 * Use scaled score in the xAPI Quiz Report. Default: false
 */
add_filter( 'uo_tincanny_data_consider_scaled_score', function ( $consider ) {
	$consider = true;
	return $consider;
} );
/**
 * Post types in the Tin Can Report dropdown. Default: post, page
 */
add_filter( 'uo_tin_can_filter_post_types', function ( $post_types ) {
	$post_types[] = 'my_cpt';
	return $post_types;
} );
/**
 * Post types used when linking quiz report rows to content. Default: post, page
 */
add_filter( 'uo_tincanny_tincan_post_types', function ( $post_types ) {
	$post_types = array( 'post', 'page' );
	return $post_types;
} );
/**
 * Column labels for the Tin Can Report.
 */
add_filter( 'tincan_table_columns', function ( $columns ) {
	return $columns;
} );
/**
 * Visible column labels for the xAPI Quiz Report.
 */
add_filter( 'tincan_xapi_table_columns', function ( $columns ) {
	return $columns;
} );
/**
 * Column definitions for the xAPI Quiz Report.
 */
add_filter( 'xapi_quiz_table_columns', function ( $columns ) {
	return $columns;
} );
/**
 * GLightbox config. closeOnOutsideClick default: '0'
 */
add_filter( 'uo_tincanny_glightbox_config', function ( $config ) {
	$config['closeOnOutsideClick'] = '0';
	return $config;
} );
/**
 * Public module URL.
 */
add_filter( 'tincanny_module_url', function ( $url, $item, $module ) {
	return $url;
}, 10, 3 );
/**
 * Whether to show the Add Tin Canny Content media button. Default: true
 */
add_filter( 'uo_display_add_tin_canny_media_button', function ( $show ) {
	$show = false;
	return $show;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top