• Resolved dave1010

    (@dave1010)


    PHP Notice: Undefined property: WPCF7_ContactForm::$user in /var/www/projects/wordpress/wp-content/plugins/contact-form-7-to-database-extension/CF7DBPlugin.php on line 490

    Looks like $cf7->user is only set if the user is logged in. You can fix this by moving the assignment down 1 line:

    --- CF7DBPlugin.php.old
    +++ CF7DBPlugin.php.new
    @@ -479,8 +479,8 @@
                 if (is_user_logged_in()) {
                     $current_user = wp_get_current_user(); // WP_User
                     $user = $current_user->user_login;
    -                $cf7->user = $user;
    -            }
    +            }
    +            $cf7->user = $user;
                 try {
                     $newCf7 = apply_filters('cfdb_form_data', $cf7);
                     if ($newCf7 && is_object($newCf7)) {

    As there’s a filter (thanks!), I’ve currently worked around this like this:

    add_filter('cfdb_form_data', function($formData) {
        // fix for PHP notice
        // Undefined property: WPCF7_ContactForm::$user in /wp-content/plugins/contact-form-7-to-database-extension/CF7DBPlugin.php on line 490
        if (!empty($formData) && is_object($formData) && !isset($formData->user)) {
            $formData->user = null;
        }
    });

    http://wordpress.org/extend/plugins/contact-form-7-to-database-extension/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP Notice in CF7DBPlugin::saveFormData()’ is closed to new replies.