Filter
uncanny-automator-pro
automator_ld_essayquiz_token_value
Filters the value of an essay quiz token before it's parsed in LearnDash.
add_filter( 'automator_ld_essayquiz_token_value', $callback, 10, 3 );
Description
Filters the value for LearnDash essay quiz tokens. Developers can modify the token's output before it's used in an automation. This hook fires after the default token value is determined but before it's returned. It allows customization of essay quiz-related data for use in triggers and actions.
Usage
add_filter( 'automator_ld_essayquiz_token_value', 'your_function_name', 10, 3 );
Parameters
-
$value(mixed) - This parameter contains the current value of the token that is being filtered, which is usually a string or an array depending on the token.
-
$parse_token_key(mixed) - This parameter contains the calculated value for the LearnDash essay quiz token.
-
$ld_essay_id(mixed) - This parameter holds the unique key for the token being parsed.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the 'automator_ld_essayquiz_token_value' filter.
* This example checks if the token key is 'user_essay_answer' and, if so,
* it appends a custom string to the essay answer.
*
* @param mixed $value The current value of the token.
* @param mixed $parse_token_key The key of the token being parsed.
* @param mixed $ld_essay_id The ID of the LearnDash essay quiz.
*
* @return mixed The modified or original token value.
*/
add_filter( 'automator_ld_essayquiz_token_value', function( $value, $parse_token_key, $ld_essay_id ) {
// Check if we are dealing with the user's essay answer token
if ( 'user_essay_answer' === $parse_token_key ) {
// Ensure the value is a string before appending
if ( is_string( $value ) ) {
$value .= ' - Processed by custom filter.';
}
}
// If the token key is something else, return the original value
return $value;
}, 10, 3 );
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
uncanny-automator-pro/src/integrations/learndash/tokens/ld-pro-tokens.php:448
break;
default:
$value = '';
break;
}
$value = apply_filters( 'automator_ld_essayquiz_token_value', $value, $parse_token_key, $ld_essay_id );
}
return $value;
}
/**
* New tokens for Groups and Courses trigger.