I hook to comment form (on comment_form_logged_in_after if user is logged in and comment_form_before_fields if not) to add 2 fields (rating and title).
These fields can be mandatory or comment will not save. These fields will not appear on comment reply or if review are not enabled for a certain post or page.
If these fields are mandatory, I've to check on comment_post (just before to save comment) if filter has run, and if not just save the comment withoud any comment_meta.
The problem is that if I try to use
has_filter('comment_form_before_fields', 'my_function_to_check');
when I hook on comment_post it ALWAYS return FALSE.
If, for example, I try to show
var_dump(has_filter('comment_form_before_fields', 'my_function_to_check'))
on comment_text filter it works.
How can I do this?
my_function_to_check
oncomment_form_before_fields
added? Could you post all relevant code — especially where the filter is added and when the function that adds the filter is called.init
instead of oncomment_form_before
?