Add toggle button to comments form

Question

I’m a bit new to wordpress and I’m working on a project that has a custom page with comments and a comments form on it. I can get the comments form to show, add a comment, watch it display on the page and everything works great.

Now I’m trying to add a button to the form. To give some context, this is for single obituary page. The idea is a user will write a comment and after that they will be able to click an icon/button that says “Light a candle”. When they check this option, I’d like to have that data also saved and displayed on the comment after it posts to the page. Is there a built in way I can do this via wordpress? I have found some snippets for adding various actions to the comment_form:

add_action('comment_form', 'add_input_privacy');
function add_input_privacy() {
    $commenter = wp_get_current_commenter();
    echo '<p class="comment-form-author"><input type="checkbox" style="..." name="privacy" value="1"/>Light a candle</p>';
}

but so far I’m not having any luck. I appreciate any input and thanks for any helpful hints.

0
justDan 4 weeks 2021-08-30T12:42:12-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse