• Resolved Roman

    (@vladroman)


    Hello.

    wpDiscuz 7.3.7

    For some reason I need to edit comments date without any change in DB.

    I can do this by replacing html after page is generated. But this is not optimal way due to the high resource intensity of this operation.

    Does wpDiscuz have any hook/filter, which allow to change date at plugin output?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support gVectors Support

    (@gvectorssupport)

    Hi Roman,

    You can enable the “Use WordPress Date/Time Format” option, then use the code below.
    The option is located in the Dashboard > wpDiscuz > Settings > General Settings tab. More info here: https://wpdiscuz.com/docs/wpdiscuz-7/plugin-settings/general-settings/#use-wordpress-date-time-format

    if (!function_exists("wpdModifyCommentDate")) {
    
        add_filter("get_comment_date", "wpdModifyCommentDate", 10, 3);
    
        function wpdModifyCommentDate($date, $format, $comment) {
            // do whatever you want
            return $date;
        }
    
    }

    Put the code in the active theme functions.php file. This article should be helpful for you; https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

    Thread Starter Roman

    (@vladroman)

    Thank you for quick and detailed answer.

    Yes, option “Use WordPress Date/Time Format” is enabled. At same time I use sorting by comment date, not ID.

    Will filter get_comment_date have effect to comment sorting in this case?
    I need to change date only in html output. Without any effect to something else.

    Plugin Support gVectors Support

    (@gvectorssupport)

    Roman,

    No, it won’t affect comment sorting at all. It just changes the date visually.

    Thread Starter Roman

    (@vladroman)

    Thank you. This works good.

    But now, after tests, I found out, that wpDiscuz comment time format looks much better. ??
    Can I correct comment time in html output, if “Use WordPress Date/Time Format” is disabled? I need this only in some rare cases, so most of time comment time will be shown with better wpDiscuz format.

    Thread Starter Roman

    (@vladroman)

    Looks like wpDiscuz generate comment time text in
    function dateDiff from includes/wc-helper.php.
    Don’t see hooks there.

    Up lvl function get_comment_template from comment-form/tpl-comment.php doesn’t have hooks too.

    So, no chance do something here?

    Plugin Support gVectors Support

    (@gvectorssupport)

    We’ll add a new hook in the wpDiscuz in future versions, so you’ll be able to get it to work with the wpDiscuz date/time format as well.

    Thread Starter Roman

    (@vladroman)

    Thank you a lot. I will wait. ??
    wpDiscuz format for comments date/time really better.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Real-time date changing’ is closed to new replies.