• Resolved mmash34

    (@mmash34)


    I just downloaded this plugin on my staging site and put the [site_reviews_form] shortcode on a blank page to test functionality. When I hit submit review, it doesn’t go through and gives me an error message “Your review could not be submitted and the error has been logged. Please notify the site admin.”

    Here’s what the console says:

    [2021-01-11 13:29:45] ERROR [Database\ReviewManager:100] Could not insert post into the database.
    [2021-01-11 13:29:45] DEBUG [Database\ReviewManager:100] Array
    (
    [comment_status] => closed
    [ping_status] => closed
    [post_content] => thanks
    [post_date] =>
    [post_name] => local5ffc991903fa1
    [post_status] => publish
    [post_title] => Great course
    [post_type] => site-review
    )

    What should I do to remedy?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    “Could not insert post into the database” is a WordPress error that is triggered by wp_insert_post.

    The first console entry shows that the error happens just after wp_insert_post is used to create the review (it’s the message from WP_Error that is triggered by wp_insert_post).

    The second console entry shows the data that was being passed to wp_insert_post in order to create the review post.

    If you are a developer, this may be of interest: https://stackoverflow.com/questions/32027256/wordpress-db-insert-error-when-using-insert-post

    I am unsure what is causing WordPress to throw an error when creating a post, likely it has something to do with your local WordPress install. If this is a staging (i.e. non-production) website and you are willing to send me some login details using the “Contact Support” section on the Help page, I could look into it for you and try to track down the cause.

    I suspect it may have something to do with your Database table charset.

    Otherwise at the very least, you will need to use the “Contact Support” section to send me the full console log and the Site Reviews system info as that may be enough to tell me how your system is configured and what is going on.

    • This reply was modified 3 years, 10 months ago by Gemini Labs.
    Thread Starter mmash34

    (@mmash34)

    Thanks for quick response. Just sent you an email with staging site access for you to check

    Plugin Author Gemini Labs

    (@geminilabs)

    Thanks!

    The error is being caused by the following code in your child theme’s functions.php file:

    function stop_modified_date_update ($new, $old) {
        $new['post_modified'] = $old['post_modified'];
        $new['post_modified_gmt'] = $old['post_modified_gmt'];
        return $new;
    }
    add_filter('wp_insert_post_data', 'stop_modified_date_update', 10, 2);

    I recommend if you are going to use that hook, that you first check that $old['post_modified'] and $old['post_modified_gmt'] exist (it won’t for new posts), and also check for the post type.

    For example, something like this:

    function stop_modified_date_update ($new, $old) {
        if (!isset($new['post_type']) || !in_array($new['post_type'], ['post', 'page'])) {
            return $new;
        }
        if (isset($old['post_modified'])) {
            $new['post_modified'] = $old['post_modified'];
        }
        if (isset($old['post_modified_gmt'])) {
            $new['post_modified_gmt'] = $old['post_modified_gmt'];
        }
        return $new;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘“Your review could not be submitted and the error has been logged”’ is closed to new replies.