wpDiscuz - WordPress Comment Plugin
Share:
Notifications
Clear all

[Solved] Agreement checkbox default for replies


wp_user
Posts: 4
Topic starter
(@wp_user)
New Member
Joined: 7 months ago

The js code from this thread works to check the main comment checkbox, in the way I have it hooked in my code below. How do I check all the reply form checkboxes as well?

https://wpdiscuz.com/community/troubleshooting/checkbox-default/

function my_wpdiscuz_autocheck_agreebox() {
    ?>
		<script type="text/javascript"> 
		jQuery('#wpdcom .wpd-field-agreement .wpd-field').prop('checked', true);
		</script>
    <?php
}
add_action('wpdiscuz_comment_form_after', 'my_wpdiscuz_autocheck_agreebox');

2 Replies
Asti
Posts: 3567
 Asti
Support
(@asti)
Support member
Joined: 4 years ago

@wp_user,

Please replace your code with the following one. It should work fine:

function my_wpdiscuz_autocheck_agreebox() {
    ?>
		<script type="text/javascript"> 
		jQuery(document).ready(function(){
			jQuery('#wpdcom .wpd-field-agreement .wpd-field').prop('checked', true);
		});
		jQuery(document).ready(function(){
                        jQuery(document).on('click', '.wpd-reply-button', function() {
                                jQuery('.wpd-form .wpd-field-agreement .wpd-field-group-title .wpd-field').prop('checked', true);
			});
		});
		</script>
    <?php
}
add_action('wpdiscuz_comment_form_after', 'my_wpdiscuz_autocheck_agreebox');
Reply
1 Reply
wp_user
(@wp_user)
Joined: 7 months ago

New Member
Posts: 4

@asti

Thanks for the help! At first the checkbox on the reply comment fields were only showing up after I click the main comment box, but I changed the hook to comment_reply_form_bar_top and that seems to be checking the box for all the forms right away. So I think it's working!

Reply
Share: