WordPress.org

Ready to get started?Download WordPress

Forums

update comment author id with wp_update_comment (2 posts)

  1. bazel
    Member
    Posted 9 months ago #

    I cannot change the user_ID with wp_update_comment. This example is working, the content is updated but not the user_ID. I tried also user_id.
    Please help

    function update_user_id( $comment_ID) {
    	 $commentarr = array();
    		  $commentarr['comment_ID'] = $comment_ID;
    		  $commentarr['comment_content'] = 'Sample content';
    		  $commentarr['user_ID'] = 1; 
    
    		  wp_update_comment( $commentarr );  
    
    	}
    
    add_action( 'comment_post', 'update_user_id');
  2. Scriptrunner (Doug Sparling)
    Member
    Posted 9 months ago #

    The function wp_update_comment() doesn't have the option to update the user id. It only updates these fields:

    • comment_content
    • comment_author
    • comment_author_email
    • comment_approved
    • comment_karma
    • comment_author_url
    • comment_date
    • comment_date_gmt
    • comment_parent

Reply

You must log in to post.

About this Topic