Skip Navigation

[Resuelto] CRED post-form not working reliable

This support ticket is created hace 7 años, 1 mes. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 42 respuestas, has 2 mensajes.

Last updated by Christian Cox hace 7 años.

Assisted by: Christian Cox.

Autor
Mensajes
#489996

Hi everyone!

In one of my projects I'm using a CRED-post-form for guest-requests regarding free rooms of a guesthouse. The form is open for the public, lays in a bootstrap-modal-window and normally works as expected: After sending the form, a new post is created and two notifications are sent (one to the guest, one to the guesthouse-owner). But again and again some guests reclaim, that they don't get answers to their requests. I tried to locate the problem, but couldn't get any answer to this:

The guests said, that they submitted the form.
They do not get a notification-e-mail.
Neither does the guesthouse-owner.
No new post is created.
No new records in the mail-log-list of "Mail Bank"-plugin.
No new errors in the smtp-error-list of "Mail Bank"-plugin.
No new PHP-errors in error.log.

But I'm logging the clicks on the form-sending-button in Google Analytics. And there are logs for the specific time-period, when the guests submitted the form. So they really clicked the button, but it seams, that nothing happened after that.

What can go wrong here? Any ideas how to solve that?
And any ideas, how I can track the guests better?
Is their a plugin or a coding-way, for sending me a notice every time immediately after a guest clicks the sending-button? Or to write a log-file with data from the form?

My client's really not happy about that. Please help me!

If you need so, that's the link: hidden link
And all "request"-buttons are linked to the CRED-form.
If you want to test, please write something like "support" and "test" in the comments, so that my client knows, that he doesn't have to answer your request. Thanks!

#490095

Hi Diana, that's troubling - I understand that you need to capture every possible lead from this form so let's try to figure out what's going on. We need to come up with a reliable way to reproduce this problem. Can you provide steps to reproduce it consistently? I've submitted this form several times (I think a few for another ticket, as well) but I don't know how to determine if the problem occurred.

The guests said, that they submitted the form.
- Can you confirm somehow that the form actually submitted successfully?
You should be able to use Google Analytics to track the user's path from the initial form view to the success message, correct? Was the user redirected to a success message in each case, like hidden link ?
Do you see any redirects with search parameters like hidden link

The second URL with search params indicates the user had JavaScript disabled, and would result in no new post being created and no email notifications sent. The first URL indicates the user was redirected correctly.

- What other details can you gather from analytics about the users who submitted the form but did not receive notifications - were they all on mobile devices? Were they all on a certain browser version? Was the site language consistent? Can you see any other patterns?

But I'm logging the clicks on the form-sending-button in Google Analytics.
Clicks and submissions are not interchangeable. A registered click on the button does not indicate the form was submitted successfully. If the form contained invalid input (like a missing number of adults), it would not submit. Some form submissions use the Enter key instead of a button click, and bots that hit your site can submit this form without triggering a click, so the numbers aren't always going to add up.

No new post is created.
If no new post was created and no PHP error messages are logged, the most likely answer is the form was not submitted successfully by the guest. Without steps to reproduce this consistently, it's going to be difficult to come up with an approach to solve this.

#490483
CREDautodrafts.jpg

Hi Christian!

I’m happy, that you are back on my case, so I don’t have to start from the beginning ? You know, in my last support-ticket, I tried to speed up the form-submission. I assumed, that the guests couldn’t wait until the form was submitted successfully. But now (with your help) this process is much faster and I implemented a notice for the guests, to be patient until they receive their success-message. So now I’m not really sure, if this was the real and one and only problem.

I can’t really tell, if all of the forms were submitted successfully. We did get a few requests from your tests, but none in the last three days. (Probably you didn’t fill in a correct e-mail-address, so you didn’t get any notification, or did you?) I don’t track the success-messages in Google Analytics, but will do so from now on. And my client (the guesthouse-owner) wants to get in touch with the last two guests to find out, if they received a success-message on screen or via e-mail. That should help a bit ...

In Google Analytics I can find those infos about the last four request-clicks, which weren’t stored in WordPress and for which we didn’t receive a notification:

  • 14.2. 1 p.m. / 15.2. 7 a.m. / 16.2. 3 a.m. / 16.2. 3 p.m.
  • Czech Rep, Prague / Romania, Napoca / South Carolina,Plymouth / UK, Charleston
  • Windows 7 / Android 6.0.1 / Mac 10.12 / Windows 7
  • desktop / mobile / desktop / desktop
  • browser: all of them in newest Chrome
  • clicked on this pages: de:angebote / en:home / en:our-rooms / en:our-special-offers
     
  • I can’t see a pattern, which would explain the problem (besides the Chrome-Browser, in which I’m testing, too). Do you?

    As you already mentioned, the click-numbers aren’t really meaningful. It’s possible, that some of them are bots. Or didn’t send the form again, after negative validation. Or whatever. But in analytics „funnel visualization“ I see two success-pages out of the last four clicks from above:

    /angebote/?_tt=1487074549&_success_message=793_1&_target=27931
    /en/our-special-offers/?_tt=1487212967&_success_message=793_1&_target=27918

    I don’t know, what the _tt-param stands for, but the _target should be the id of the new created post, shouldn’t it? I can’t find those posts in my custom post type. And these IDs aren’t stored in the wp_posts-table in mySQL either.

    But I do see strange posts in wp_posts – there are plenty of CRED-auto-drafts with todays date (see screenshot of wp_posts). Don’t know, if there’s a reason for that?

    You wrote about the request-behaviour when JavaScript is disabled. I’m aware, that the website doesn’t work properly when JS is disabled. Perhaps I should integrate a warning about that. But a guest without JS couldn’t be tracked in Google Analytics because that is also based on JS, or can he?

    To make sure that my error-log is working – I have this code in my wp-config.php

    ini_set('log_errors',TRUE);
    ini_set('error_reporting', E_ALL);
    ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
    define('WP_DEBUG', false);
    

    This should write all php-errors in error_log.txt in my home-directory. Is that correct? If yes, no errors in the file …

    Hope you can find a new pattern out of that all and we can get rid of this problem! Read you ... ?

    #490520
    0216-2.jpg
    0216-1.jpg
    0215.jpg
    0214.jpg

    Hi again! I digged deeper into Google Analytics statistics and found the "user-explorer" which tracks the path of every user. If I do so for the 4 customers, who clicked my submit-button in the last three days, I can see, that all of them were redirected to the success-message (see screenshots).

    So the form was submitted, am I right?
    And the post IDs (_target) should be 27931, 27921, 27922 and 27918.
    None of them are in my database.
    That's quite alarming!

    My last confirmed and working request (before the 4 above) was on 13th Feb and has the ID 27930. It bothers me, that the last three attempts should have a lower ID. Is that possible at all?

    I don't know, if that's a normal thing, but in my database in wp_posts there are many IDs which aren't used at all. So for example, there are no post-IDs between

  • 27930 and 27915
  • 27915 and 27843
  • 27843 and 27317 ...
     
  • Hopefully you have a spark of an idea, what I can do here ...

    #490603

    Okay thanks for the details. I'm continuing to investigate but I believe you have a typo in your wp-config.php file. WP_DEBUG should be true, not false. Can you please go ahead and change that setting to see if any errors are logged?

    define('WP_DEBUG', true);
    
    #490643

    Can you confirm you have set your CRED form to create a Post that is set to "Published" status?
    Toolset > Post Forms > YourForm > Edit

    Can you tell me if you have anything in functions.php that may be hooking into the CRED API (like cred_save_data), and if so, please paste it here.

    Can you confirm you have a Post created by me, using an On The Go Systems email address, around 18:21 GMT today? I received a confirmation message by email.

    #490766

    Hi Christian!

    I thought, wp_debug can be false, when log_errors is true? But okay, I changed my config to:

    ini_set( 'log_errors',TRUE);
    ini_set( 'error_reporting', E_ALL);
    ini_set( 'error_log', dirname(__FILE__) . '/error_log.txt');
    define( 'WP_DEBUG', true);
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    

    YES, CRED form for creating post with published status.
    YES, there is a new post with your e-mail-adress.
    YES, I got a confirmation e-mail, with your request.
    YES, the mail-log shows both e-mails.

    There is a new mail-error, which shows an error in wpml-translation, but with todays timestamp. Did you get a mail in English?

    [18-Feb-2017 06:53:10 UTC] PHP Warning:  array_key_exists(): The first argument should be either a string or an integer in /var/www/tophosting/cablelink/vhost_43642/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-synchronization.class.php on line 59
    

    And YES, I have a few hooks to CRED, but they seem to work properly:

     
    // Replacing html for correct JSON-format - for Checkboxes with AKTIONEN in CRED
    add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
    function prefix_clean_view_output( $out, $id ) {
        if ( $id == '914' ) {
            $start = strpos( $out, '<!-- wpv-loop-start -->' );
            if ( 
                $start !== false
                && strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
            ) {
                $start = $start + strlen( '<!-- wpv-loop-start -->' );
                $out = substr( $out , $start );
                $end = strrpos( $out, '<!-- wpv-loop-end -->' );
                $out = substr( $out, 0, $end );
            }
        }
        return $out;
    }
    
    // Convert datepicker-dates of ANFRAGEN to unix timestamp
    add_action('cred_before_save_data', 'convert_date_to_unix_timestamp',10,1);
    function convert_date_to_unix_timestamp($form_data){
        if ( $form_data['id'] == 793 ){
            $_POST['wpcf-anfr-anreise']['datepicker'] = strtotime($_POST['wpcf-anfr-anreise']['datepicker']);
            $_POST['wpcf-anfr-abreise']['datepicker'] = strtotime($_POST['wpcf-anfr-abreise']['datepicker']);
        };
    }
    
    // Giving ANFRAGEN the date and email-adress as custom title
    // Writing checked checkboxes into post-meta 
    add_action('cred_save_data', 'my_save_data_action',10,2);
    function my_save_data_action($post_id, $form_data){
        if ( $form_data['id'] == 793 ){
            $anfrdate = get_the_time('d.m.Y', $post_id);
            $anfrsender = get_post_meta( $post_id, 'wpcf-anfr-email', true );
            $custom_title = $anfrdate." / ".$anfrsender;
            $my_post = array(
                'ID'            => $post_id,
                'post_title'    => $custom_title,
                'post_name'     => $custom_title,
            );
            $aktionen = get_post_meta($post_id,'wpcf-aktionen-checked',true);
            if ( !empty($aktionen) && $aktionen != "" ) { 
                $aktionstext = "";
                foreach ($aktionen as $aktion) { 
                    $aktionstext .= "+ ".implode(', ', $aktion)."  ";
                };
                add_post_meta( $post_id, "wpcf-anfr-aktionen", $aktionstext, true );
            }
            wp_update_post( $my_post );
        }
    }
    
    // Add a reply-to-email for CRED (for form with ID 793 and notification "An Pension Herzog")
    add_filter('cred_mail_header', 'add_replyto', 10, 4);
    function add_replyto($headers, $formid, $postid, $notname) {
        if ( $formid === 793 && $notname == "An Pension Herzog") {
            $useremail = get_post_meta($postid, 'wpcf-anfr-email', true);
            $newheaders = array( 'Reply-To: '.$useremail ); 
            return array_merge($headers, $newheaders);
        } 
    }
    

    So what do you think?

    #491877

    Hi Christian! Any news on this?

    I'm now checking all of my CRED-datas on a daily basis and there are no errors in my error-log-File, but found plenty of the same errors in my Mail Bank Plugin. Strange, that the error-log-File doesn't show any of them ... Here are the errors in my mail-log-File:

    PHP Notice:  Trying to get property of non-object in /myhost/wp-content/plugins/cred-frontend-editor/embedded/classes/CRED.php on line 121
    
    PHP Notice:  Trying to get property of non-object in /myhost/wp-content/plugins/cred-frontend-editor/embedded/classes/Form_Builder.php on line 1132
    

    The first one shows up more often, than the other one. Is that anything, that could help us to investigate further?

    Today GoogleAnalytics counted one new click and one success-message-page, but again there is no related post in the database and no notifications. Yesterday there was one, too, but this one worked very well ...

    #492007

    I'm looking over your add_replyto function and it concerns me that you are not returning anything if this conditional evaluates as false:

    if ( $formid === 793 && $notname == "An Pension Herzog") {
    

    If this evaluates "true", then you return your merged array of $headers and $newheaders. That seems correct. However, if it evaluates false, you do not return anything. Since you are not returning the expected array, that could lead to the PHP warning you mentioned. It seems like there should be a fallback return $headers outside of the "if" block.

    There is a new mail-error, which shows an error in wpml-translation, but with todays timestamp. Did you get a mail in English?
    Yes, I did receive an English confirmation email.

    #492046

    Okay, Christian, I added this:

    else { return $headers; };
    

    And tested a new request, everything worked fine (as always, when I test by myself) and no new errors (neither in error-log.txt nor in mail-error-log). But I'm not sure, if this is all, what went wrong in the past ...

    #492102

    Okay, so no obvious errors or problems...yet. Please let me know if you continue to see "missing" posts. We can continue to troubleshoot if you see anything odd.

    #492650
    errorLogs.jpg
    WordfenceLog.jpg
    GoogleAnalytics.jpg

    Hi Christian, I'm afraid, nothing changed.
    GoogleAnalytics shows a new form-submit and a new thanks-message-page for today morning. And in Wordfence I can have a look at the same timestamp and can see, that it wasn't a bot, it was someone from Netherland. Got no confirmation mail, no new post is created, the post-number which shows up in the link, doesn't exist in the database. All the same ...

    And now the two errors are back again:
    the one in CRED.php on line 121
    and also the one in Form_Builder.php on line 1132.

    I'm getting frustrated ...

    #492729

    I understand, this should be working and it should not be so difficult to troubleshoot. I just submitted the form 3 times and received no emails, so I can confirm that is not behaving as expected. I would like to have a recent copy of your site so I can pass this information to my developers. Can you create a new clone in Updraft Plus, or show me how to create one?

    #492750

    I just created a new backup for you. Do you still have your credentials to my website?

    Today I wanted to test, if the old version of mySQL could cause the problems. I tried to connect to one of my newer databases (mySQL 5.5), but I don't have access from my clients website to my own databases. They have to be on the same webserver ...

    #492796

    Yes thanks, I still have credentials. I will download the clone and try to get a resolution for you as soon as possible.

    This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.