Support » Plugin: Post My CF7 Form » Submited form data gets cleared on status change (PHP.7.4)

  • Resolved hhnatoufi9

    (@hhnatoufi9)


    Hi,

    Recently I updated a project from PHP 7.0.X to 7.4.6.

    In a page I have users filling a form that when submitted gets posted in another page, this was working fine back in 7.0.X, but from 7.2 above, when the form gets filled in and submitted, the final result is a empty post, with the default title: CF7 2 Post.

    When uploaded, the form runs through this add_action:
    add_action( ‘cf7_2_post_status_OLX’, ‘publish_new_OLX’,10,3);
    /**
    * Function to change the post status of saved/submitted posts.
    * @param string $status the post status, default is ‘draft’.
    * @param string $ckf7_key unique key to identify your form.
    * @param array $submitted_data complete set of data submitted in the form as an array of field-name=>value pairs.
    * @return string a valid post status (‘publish’|’draft’|’pending’|’trash’)
    */

    function publish_new_OLX($status, $ckf7_key, $submitted_data){
    /*The default behaviour is to save post to ‘draft’ status. If you wish to change this, you can use this filter and return a valid post status: ‘publish’|’draft’|’pending’|’trash’*/
    return ‘publish’;
    }

    Commenting this add_action, the form gets saved as a draft naturally.
    Also, running with the add_action I don’t seem to be getting any error messages.
    And I read this topic: https://wordpress.org/support/topic/cant-use-function-return-value-in-write-context-php-7-2/ though the solution didn’t work for me…

    Please, if needed to provide any more info just tell me, I’ll try to display as much as I can…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    the final result is a empty post, with the default title: CF7 2 Post.

    ok, that’s odd. This usually happens when you use a filter and fail to return the filtered value.

    add_action( ‘cf7_2_post_status_OLX’, ‘publish_new_OLX’,10,3);

    this should really be add_filter.

    Did you add any new custom filter recently which could lead to this error?

    Are you using this plugin on the olx website?

    I will run a few tests on my server and get back to you.

    Hi Aurovrata Venet, great timing..

    First I must say apologise for not mentioning the wordpress version which was at the time 5.4.1, the lastest that is. And no, the “olx” was just a temporary name that stayed..

    I should update you with our current progress and status:
    1. We ended up downgrading wordpress to 5.2.5 and php 7.0, the last know stable and working version of the functions
    2. After some long code digging and debuging the problem was traced back to being possibly caused by the custom theme currently applied (which isn’t a wordpress official, so no support guaranteed) and the native wordpress post.php.

    Because this plugin and its functions where part of the core features, it was the initial suspicion, but was concluded that no, it was only being affected.

    As for running wordpress and php latests versions with a differente, wordpress official theme, we did not try that, so if it all runs smooth, please do share..

    Sorry for the confusion, and thank you for the reply and your time!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    thanks for the update, I am glad you to know you are able to resolve your issues. Happy coding!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.