When adding a hook with add_action()
, the 4th argument is the number of arguments accepted by the callback function:
$accepted_args
(int) (Optional) The number of arguments the function accepts.
Default value: 1
Your callback function, CanvasLd::learndash_new_assignment_comment
, accepts two:
static public function learndash_new_assignment_comment( $comment_id, $comment ) {
Since the default number of arguments passed to the callback is 1, $comment
is not sent to the callback function. This causes a fatal error because the function requires 2 arguments as written.
So make sure to specify the number of arguments with add_action()
:
add_action( 'wp_insert_comment', array( 'CanvasLd', 'learndash_new_assignment_comment' ), 10, 2 );