Changing $commentdata
-
I’m not sure where to put this but within the past couple of point releases, something has changed in the comment handling. I see there have been some minor changes to the base code in /wp-includes/comment.php but I don’t see how it’s created the condition I am experiencing.
I have a custom function that’s been running for several years without issue that hooks into the preprocess_comment filter hook to read the comment_author_email value in $commentdata. The function had filtered and set the $commentdata[‘user_id’] value and passed is back for processing by wp_new_comment(). The custom function runs after Akismet first handles the comment and is still functioning properly. However, something is butting in and resetting $commentdata[‘user_id’] to 0 before it gets to wp_insert_comment(). The only thing I could figure was something was hooking into the filters in wp_filter_comment() but it could only be Akismet. Akismet has become so complicated that I can’t tell if it’s actually manipulating other key=>value pairs $commentdata. I don’t have any other plugins that handle comments.
Anyway, I fixed the behavior by having the custom function set both $commentdata[‘user_id’] AND the seemingly deprecated $commentdata[‘user_ID’] with the same value.
The core code has several ternary operators that deal with the backwards compatibility to handle $commentdata[‘user_ID’] in several functions, including wp_new_comment() and wp_insert_comment().
Anyway, I thought I would post this in case someone experiences similar variances in comment handling.
- The topic ‘Changing $commentdata’ is closed to new replies.