0
votes

I'm working with a rather unconventional use case for Wordpress.

I've created a site available only to registered users, and after they've submitted a comment to a post, the form to submit a new comment disappears. It's replaced by a textarea displaying the content of their comment (and only their comment - not the comments of others).

I cannot figure out how to actually allow the user to edit their comment using the textarea field. I've spent hours searching Google, the Wordpress documentation, and Stack Exchange with little luck.

This is the closest I've come...

<form name="post" action="<?php echo get_option('siteurl'); ?>/wp-admin/comment.php?action=editcomment&c=<?php comment_ID() ?>" method="post" id="post">
    <textarea><?php comment_text() ?></textarea>
    <input class="btn" type="submit" name="submit" value="Update" />
</form>

Unfortunately, that just redirects you to the backend editor for the comment. I'd like to process the update entirely on the front end.

Anyone have any insights on where to start?

2

2 Answers

1
votes

please check out this plugin, which is already created, so after posting a comment users will be able to edit it for a limited time.

No need to create something new nowadays, try searching for a plugin first :) .

Plugin link - http://wordpress.org/extend/plugins/wp-ajax-edit-comments/ .

If you are creating new theme, then you will have to create new function which shows comment form after edit button is pressed, and insert all current comment values in it.

This function should be useful - http://codex.wordpress.org/Function_Reference/edit_comment_link

0
votes

Check out this function wp_update_comment you can start from that. I already did something like this on that past. The function is pretty self explanatory.