WordPress.org

Ready to get started?Download WordPress

Forums

Editing Comment Meta in edit comment admin panel (10 posts)

  1. BAC
    Member
    Posted 4 years ago #

    Hi,

    Have spent the last few days trawling the web trying to find a solution for this. I really hope someone can help.

    I have extra comment fields for comments ($myorg for example) and i capture and output this OK.

    [if anyone wants to know how I did this: http://www.soapboxdave.com/2010/02/using-wordpress-comment-meta/

    Now I need to add the ability to edit the custom comment meta fields in the Edit Comment admin pannel.

    I think that I need to use the manage_comments_custom_column action hook but can not seem to find any examples or any documentation on the codex.

    I have seen a couple of people asking for a similar solution but no useful replys.

    This will be the first time I have tried to edit a write panel in wordpress so please keep in my my limited experince.

    Thanks for any help on this. Would be so much appreciated!

    Cheers
    BAC

  2. Mark / t31os
    Moderator
    Posted 4 years ago #

    Have a look at the information on manage_posts_custom_column and manage_posts_column, the same procedure (with minor naming differences) should still apply.

    Assumption on my part, but i'd expect it to behave the same as the manage post column functions.

    Post back if you still get stuck.. ;)

  3. BAC
    Member
    Posted 4 years ago #

    Thanks for the reply T31os,

    Hit a bit of a brick wall on this.

    I tried to start by just getting the value of the commentmeta $myorg into a new column in the edit comments panel but struggling to get it to work.

    I would have thought this should work?

    function EditCommentsColumnsHeader($columns) {
    	$columns['myorg'] = __('Org');
    	return $columns;
    }
    
    add_filter( 'manage_comments_column', 'EditCommentsColumnsHeader' );
    
    function EditCommentsColumnsRo($columnTitle, $comment_ID){
    	if($columnTitle == 'Org'){
    		echo $myorg;
    	}
    }
    
    add_filter( 'manage_comments_custom_column', 'EditCommentsColumnsRow', 10, 2 );

    Am I on the right track?

    Cheers
    BAC

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    Looks about right, though there's a small error in your function name here.

    function EditCommentsColumnsRo($columnTitle

    Missing the w on the end of the function name.

  5. jigarshah.radixweb
    Member
    Posted 3 years ago #

    Hi ,

    function EditCommentsColumnsHeader($columns) {
    $columns['myorg'] = __('Org');
    return $columns;
    }

    add_filter( 'manage_comments_column', 'EditCommentsColumnsHeader' );

    function EditCommentsColumnsRow($columnTitle, $comment_ID){
    if($columnTitle == 'Org'){
    echo $myorg;
    }
    }

    add_filter( 'manage_comments_custom_column', 'EditCommentsColumnsRow', 10, 2 );

    this code is not working.

    i want to add custom fields on Comment management screen of admin panel and also want to add more fields on edit comment screen after Editor. but unfortunately i cant found any plugin or any action in word press which allow me to do this.

    any one know how it possible?

    many thanks
    JIGAR

  6. asafche
    Member
    Posted 3 years ago #

    the problem is that there isn't a filter for managing comments column.
    There is a action hook in the name of "manage_comments_custom_column"
    but there isn't a filter hook to go with, like "manage_comments_columns"
    I've looked everywhere for that filter hook... and nothing.

    What can be the solution?

    Cheers,
    Asaf.

  7. serpico
    Member
    Posted 3 years ago #

    I too would like a solution to this. Not found it yet.

  8. Adrian Toll
    Member
    Posted 3 years ago #

    // ADD THE COMMENTS META FIELDS TO THE COMMENTS ADMIN PAGE
    
    function comment_meta_row_action( $a ) {
    	global $comment;
    	echo '<div class="comment-meta">';
    	echo get_comment_meta( $comment->comment_ID, 'town', true );
    	echo '</div>';
    	return $a;
    }
    
    add_filter( 'comment_row_actions', 'comment_meta_row_action', 11, 1 );

    Akismet "User X marked this as spam" message is priority 10, so I've set this function to 11.

    I've to admit that I'm not sure exactly what $a does here, but it seems to be essential for a loop that WordPress uses when writing out rows in the comment details.

  9. serpico
    Member
    Posted 3 years ago #

    @adriantoll - that code will add the comment meta data to the main comments list page. I was looking to be able to add the comment meta data to the edit comment form to be able to make the comment meta editable... but last I don't think this is currently possible.

  10. Adrian Toll
    Member
    Posted 3 years ago #

    Ah, yes - apologies for the confusion - this post came up during a search that I was doing for a way to display rather than edit. If there's no hook I guess the only way would be to write a plugin which enabled you to manage them from a Settings or Tools page - but I'd hope that a hook will be added sometime soon to make this possible in the default comments interface because it seems like a reasonable request to make data stored in commentsmeta editable.

Topic Closed

This topic has been closed to new replies.

About this Topic