uo_tincanny_actor_mbox
Filters the email address of the user associated with a Tincanny actor before saving it. This allows modification of the actor's email.
add_filter( 'uo_tincanny_actor_mbox', $callback, 10, 2 );
Description
Filters the email address used to identify the actor in Tin Can API statements. Developers can use this hook to modify the user's email address before it's sent to the LRS, enabling custom actor identification or privacy considerations.
Usage
add_filter( 'uo_tincanny_actor_mbox', 'your_function_name', 10, 2 );
Parameters
-
$user_email(mixed) - This parameter holds the email address of the user currently interacting with the content, which can be filtered and modified.
-
$user(mixed) - This parameter contains the email address associated with the current WordPress user.
Return Value
The filtered value.
Examples
add_filter(
'uo_tincanny_actor_mbox',
function( $user_email, $user ) {
// If the current user is logged in, use their registered email address.
// Otherwise, fallback to a generic anonymous email.
if ( is_a( $user, 'WP_User' ) && ! empty( $user->user_email ) ) {
return $user->user_email;
}
// Fallback for logged-out users or if user object is malformed.
return '[email protected]';
},
10, // Priority
2 // Accepted args (uo_tincanny_actor_mbox, $user_email, $user)
);
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/includes/TinCan_Content_List_Table.php:162
src/uncanny-articulate-and-captivate/classes/Shortcode.php:374
$src = site_url( $post->url );
$src = apply_filters( 'tincanny_module_url_preview', $src, $post );
$user = wp_get_current_user();
$user_data = is_a( $user, 'WP_User' ) && isset( $user->data ) ? $user->data : false;
$user_name = $user_data && isset( $user_data->display_name ) ? $user_data->display_name : 'Unknown';
$user_name = str_replace( array( '"', "'" ), array( '', '' ), $user_name );
$user_email = $user_data && isset( $user_data->user_email ) ? $user_data->user_email : '[email protected]';
$user_email = apply_filters( 'uo_tincanny_actor_mbox', $user_email, $user );
$args = array(
'endpoint' => UCTINCANInit::$endpint_url . '/',
'auth' => 'LearnDashId' . $post->ID,
'actor' => rawurlencode(
sprintf(
'{"name": ["%s"], "mbox": ["mailto:%s"]}',