update_comment_meta example

if ( false === $result ) {
        if ( $wp_error ) {
            return new WP_Error( 'db_update_error', __( 'Could not update comment in the database.' )$wpdb->last_error );
        } else {
            return false;
        }
    }

    // If metadata is provided, store it.     if ( isset( $commentarr['comment_meta'] ) && is_array( $commentarr['comment_meta'] ) ) {
        foreach ( $commentarr['comment_meta'] as $meta_key => $meta_value ) {
            update_comment_meta( $comment_id$meta_key$meta_value );
        }
    }

    clean_comment_cache( $comment_id );
    wp_update_comment_count( $comment_post_id );

    /** * Fires immediately after a comment is updated in the database. * * The hook also fires immediately before comment status transition hooks are fired. * * @since 1.2.0 * @since 4.6.0 Added the `$data` parameter. * * @param int $comment_id The comment ID. * @param array $data Comment data. */
// this fires on wp_insert_comment. we can't update comment_meta when auto_check_comment() runs     // because we don't know the comment ID at that point.     public static function auto_check_update_meta( $id$comment ) {
        // wp_insert_comment() might be called in other contexts, so make sure this is the same comment         // as was checked by auto_check_comment         if ( is_object( $comment ) && !empty( self::$last_comment ) && is_array( self::$last_comment ) ) {
            if ( self::matches_last_comment( $comment ) ) {
                load_plugin_textdomain( 'akismet' );

                // normal result: true or false                 if ( self::$last_comment['akismet_result'] == 'true' ) {
                    update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
                    self::update_comment_history( $comment->comment_ID, '', 'check-spam' );
                    if ( $comment->comment_approved != 'spam' ) {
                        self::update_comment_history(
                            $comment->comment_ID,
                            '',
                            'status-changed-' . $comment->comment_approved
                        );
                    }
                } elseif ( self::$last_comment['akismet_result'] == 'false' ) {
                    update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
                    self::update_comment_history( $comment->comment_ID, '', 'check-ham' );
                    
Home | Imprint | This part of the site doesn't use cookies.