This topic contains 3 replies, has 2 voices, and was last updated by  morganrt 3 years ago.

  • Author
    Posts
  • #6912

    morganrt
    Participant

    Hello,
    I’m starting out with Piklist and (to some extent) WordPress. I’d like to add some custom fields to the WP comment form. I also need to modify slightly what happens when the submit button is pressed (another site needs to be updated, but that’s separate to this question).

    I’m just wondering if all that’s required is to drop the piklist form shortcode into a comment hook. Do the piklist field values get added automatically to comment_meta? Does the piklist submit button replace the default submit button, or do I have to do anything else to it?

    Many thanks,
    Morgan

  • #6919

    Steve
    Keymaster

    @morganrt– You don’t need to drop in a shortcode, you can just use a Piklist field. I’m not exactly sure which hook to use, but the function can look like this:

    function extra_comment_fields() {
    	piklist('field', array(
    		'type' => 'text'
    		,'field' => 'my_label'
    		,'scope' => 'comment_meta'
    		,'label' => 'My label'
    	));
    }
    

    This can go in your functions.php file.

    Let us know if this works for you and which hook you ended up using.

  • #6920

    Steve
    Keymaster

    I just tried hooking to these functions, and the field renders but it doesn’t save.

    Looks like a bug. I’ll put in a ticket for it but it may take a while.

  • #6925

    morganrt
    Participant

    Hello,
    Thanks for the reply. I was using the shortcode because all the piklist fields are in a file in the metabox folder. I’ve been trying to keep things as close as possible to the documentation.

    Before I heard from you, I found that the shortcode with the comment_form action worked when placed in my plugin file.

    function my_comment_form() {
    echo '<p class="comment-form-comment"> '.
    	do_shortcode('[piklist_form form="comment_form-metabox" add_on="toggle360"]').' </p>';
    }
    add_action( 'comment_form', 'my_comment_form' );
    

    This will save when I press the submit button. The shortcode added to the appropriate place in the theme displays but its submit button does not display.

    Now I just need to figure out how to remove the default submit button!

    Thanks,
    Morgan

You must be logged in to reply to this topic.