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 );
Related Posts:
- Disable comments on all posts/pages
- Stop WordPress redirecting comment-page-1 to the post page?
- Importing old Disqus comments into WordPress
- How to add a class to the comment submit button?
- Would switching to InnoDB from MyISAM improve performance of comments table?
- Linking to Page Showing Only Comments Without Parent Post
- Post Comments using WP REST API v2 in WordPress
- Show content only if member left a comment
- Parent comment’s author name
- get_comments_number of depth-1 (Level 1) (1 post)
- Using filter to add additional fields to comment_form()
- Disable wordpress comments API
- List Recent Comments from Across a Multi-site Network
- Comments waiting but no comments found
- Programmatically block commenting by restricting view of comment form
- Number of External Links in Comments – Moderation Option
- Disqus over the default commenting engine, what are some pros and cons?
- Comments screen in backend, how to disable Quick Edit | Edit | History | Spam | for non admins
- Plugin from WordPress.com for comment notification…available? [closed]
- How to add text to comment form #content textarea?
- Get most active users sort by comment count
- Passing arguments to wp_list_comments callback function
- What are the additional fields in wp_comments used for?
- comments_template not working correcly in custom template files
- Why are my comments closed?
- On WordPress 4.4, how to get the post id using the comment_post hook
- Create a “Reject” action for comments?
- How to change style of Disqus comment count on main page
- Adding another arg to comments_popup_link
- Exclude Duplicate Posts in this SELECT Query
- List User Comments on User Profile BuddyPress [closed]
- Changing “submitted on date” of comments
- Filter custom comment type from Manage Comments & Dash Widgets
- How to allow more HTML tags in comment for a certain comment_type
- How to deal with spam comments and distinguish them from non-spam comments?
- Threaded comments not working
- comment_post action hook running on page load instead of after a comment is posted
- Error While Sending Comment
- How to get all comment authors of a single post?
- Get return value of wp_insert_comment (comment ID)
- comment_reply_link not work with me
- have_comments() does not work
- How to use the ‘comments_number’ filter?
- Problem with Comment link in Blog [closed]
- How to allow duplicate comments AND without comment text
- Remove the deleted user comment
- How do i hide all comments from logged out users
- Show Social Sharing Buttons And Facebook Comments In Lightbox Modal Dialog (Image Overlay)?
- Grant a person permission to moderate all comments on a blog without giving them the ability to edit other peoples post
- How do I automatically insert some text in the comment textbox on submit?
- I cannot view the comments
- Problem with WordPress Comment
- In wp_list_comments comment dates won’t work?
- Where are comment ratings stored?
- Comments change the template name
- how to SELECT for the current post id?
- WordPress scruity issue – Totally disable all comments by CSS — secure enough?
- wp_new_comment requires author url and author email
- Replying to comments
- Custom comment link
- How to display the user’s comment status on the front end
- get_comments_number() vs. get_post_field( ‘comment_count’, ID )
- Where are comments coded when using custom theme?
- unsetting required fields in the comment reply form
- What is the point of get_comment_count() if you cannot limit by a comment type?
- Wrong IP address in comment section
- Problem code and show comments
- Comments turned off, but ‘Leave a reply’ link still there [duplicate]
- How to output number of comments with link to comments
- How do I make Twenty Ten display comments on the home page?
- Allowing WordPress.org/com accounts on a self-hosted install
- How to remove the “comments” bit that appears next to or below the posts
- Sort post comments from newest to oldest in pagination
- Post comments don’t show
- How do I add custom field to Admin comment form and display
- Using Disqus with headless WordPress setup?
- Attaching author tag to the comment
- Pre- Approved Comment Capability
- Delete comments function
- Comment form not working
- How to show a “Comments Are Closed” message on posts where comments have been closed?
- Comments pagination on author page
- Comments page id wp_list_comments
- Inserting comments via a procedure
- wp-editor-area textarea disapear on cancel-comment-reply-link click
- Conditionally process comments while ignoring replies
- Required Field for Comment parent only?
- Can I use WP comments for custom tables?
- How can I have a full comments.php for an easy editing of all its aspects?
- Transfer comments from one domain to another
- WordPress is adding above html
- Passing user meta through comment form
- writing a plugin, how to disable the comment form altogether?
- Function to get a list of all comments on 1 post [closed]
- Display DISQUS on homepage
- How to stop a specific person to comment on my blog? [closed]
- Auto delete WordPress comments
- Query comments with non-empty ‘author_url’ value on Admin Comments Screen
- Customize the new comment notifications sent to the post author after the comment is approved
- Get approved comments or comments that the author is me