Forums

Adding custom comment field to comment cookie (1 post)

  1. devnl
    Member
    Posted 4 months ago #

    Hi,

    I've recently implemented a custom comment field using the following code:

    global $extra_fields;
    $extra_fields = array(
    	'gamertag' => '<label for="gamertag">Gamertag</label><input id="gamertag" name="gamertag" type="text" value="" size="30">'
    );
    
    add_filter('comment_form_default_fields','extra_fields');
    
    function extra_fields($fields) {
    	foreach($extra_fields as $extra_field_key => $extra_fields_html){
    		$fields[$mm_extra_field_key] = $mm_extra_fields_html;
    	}
    
    	return $fields;
    }

    This adds the field like a charm, however I would also like the value provided to be saved to the cookie WordPress writes when you post a comment. That way, people don't always have to provide the custom field each time they post a comment. It's quite confusing for a user to see that his name and e-mail are remembered, but the custom field isn't. Does anyone have a solution on how to do this?

    Thanks in advance!

Reply

You must log in to post.

About this Topic