Adding Comment Policy to Comment Form

Hi,

Hope you all are doing well.

I am trying to add the following code in our child theme’s functions.php file to add a comment policy before they comment:

// START Commment Policy
function tips4gamers_comment_text_before($arg) {
    $arg['comment_notes_before'] = "<p class='comment-policy'>We're happy you have chosen to leave a comment. However, please keep in mind that comments are moderated according to our <a href='https://example.com/comment-policy/'>comment policy</a>.</p>";
    return $arg;
}
  
add_filter('comment_form_defaults', 'tips4gamers_comment_text_before');
// End Comment Policy

However, it does not populate anything for our Pro theme but it does populate in all of our AMP pages. Is there something I am doing wrong? Here is an example URL - https://www.tips4gamers.com/pro-madden-21-rebuild-tips-for-sim-user-play/.

We have created our own custom layout and are using the “Comment Form” element.

I have cleared all caches as well.

Thanks and regards,

Josh

Hello Josh,

Thanks for reaching out.

I have tested your code and it is working as expected.

Please check if your child theme is active. And also, I found out that you are using Cloudflare. please log in to your account, purge your site cache and test your site again. If that does not work, we would be happy to investigate further. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
- Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

Best Regards.

1 Like

Hi Rue,

I have cleared my cache and my child theme is active and working as there are other functions added.

If it works then it has to be a caching issue. I faced something similar when our header did not work (I think you helped with that issue). I am just going to wait it out because it will most likely pop up. If not, I will contact you guys again. Thank you for your help and for confirming it works.

Thanks and regards,

Josh

Hi Josh,

Try purging all your caching features.

Or if purging cache did not work, please do a Testing for Plugin Conflict

Please note that we don’t provide support for any customization here is the forum.

Thanks,

So I gave it some time as you can see. I never saw it even after the allotted time.

I deactivated every plugin we have and put Cloudflare in Development Mode. I then cleared my browser’s cache and nothing changed. With caching completely disabled and cleared, the comment policy was never implemented.

See note. I am not sure what to do from here?

Hello Joshua,

I have logged in to your site and I found out that you have some comment-related plugins. Could you please deactivate them all while we are testing? If you have a staging site or any unused site, it would be much better so that we do the troubleshooting in the staging area so that we can deactivate all the plugins leaving only the child theme with your code in it.

Yes, I can confirm that the code is working perfectly in our local testing servers. It is just not working in your site which is unusual.

Thanks.

Hi Rue,

I have created a staging site and all of the credentials are in the note. Let me know if you have any issues.

Also, caching/performance is completely disabled on the staging site.

Thanks and regards,

Josh

Also, if something worked on the staging site (i.e. a plugin deactivation) and you would like to test it on the live site, you can go ahead and do so.

Hey Joshua,

Try deactivating the comment plugins as suggested by Runel. Friech also mentioned testing for a plugin conflict.

If testing for a plugin conflict doesn’t resolve the issue please forward this issue to a coder that knows how to fix the custom code to work on your site.

Friech already mentioned previously that we do not provide support for custom development. We went beyond that anyway by testing the code but that is as far as we can go. I hate to be the one to say this but we can’t provide further help.

Thank you for understanding.

Hi Christian,

Thank you for your response.

No worries, I completely understand and I am grateful you guys have done this. You all are much appreciated, thank you.

As you can see, I have already done that.

And makes sense, I will do that. Thank you for the help, it was greatly appreciated!

Best regards

You are most welcome.

The other comment plugins, unfortunately, do not have a part in hindering it from showing up.

I did have a few things/questions in regards to the custom code I implemented for the comment policy.

How is it not working when it is working in your Pro theme development and I am using your theme?

  1. I have created a staging site and deactivated all plugins and bypassed it from ANY and ALL cache.
  2. I switched to the Pro parent theme (instead of the Pro child theme) and it still would not work even with every plugin deactivated.
  3. (for the main site/staging site) I switched to the default WordPress theme and the code worked just fine.

I do want to mention and for you to take note that I even disabled our custom layout and went back to default and nothing has changed.

  • If the code works just fine on a WordPress default theme (Twenty Twenty-One) with all of the plugins enabled or disabled, how could it not be theme-related?
  • Since I have activated the Pro theme instead of the child theme and deleted all CSS code I have added and it still doesn’t work with or without the plugins enabled, what could be causing it if it is not theme-related? I am very curious about this.

All of the above tests were done with every plugin enabled/disabled and plugins had no impact.

If you want to take another look for yourself you can see the note attached.

From the looks of it, there is not a developer out there that can make that custom code or any other custom code for a comment policy work on our site.

Also, I realize this is custom code and you do not provide support for custom code, but it is custom code specifically for WordPress and there seems to be an issue with the theme parsing that code even though the Pro theme uses the standard WordPress code for comments.

I believe there may be a bug in relation to adding to the standard WordPress comments form.

Hello Joshua,

Yes, we do no provide support for any custom code. There has to be a bug or conflict somewhere which could be the reason why your custom code is not working.

Thank you for your understanding.

Thank you for that. I understand.

I actually found the fix. I downloaded the WP Reset – Most Advanced WordPress Reset Tool plugin and chose purge cache in the settings of the plugin.

It was storing some cache that affected other things of the site as well.

Hey Joshua,

It is good to know that you have figure out the cause of the issue. We really appreciate for letting us know.

Cheers.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.