Skip Navigation

[Resolved] $_POST Variables are Being Destroyed or Removed Before Hook Can Run

This thread is resolved. Here is a description of the problem and solution.

Problem:

We created a plugin to dump the $_POST variables (as a test) and nothing is returned from the Toolset User Form.

Solution:

This is a custom PHP codes problem, it does work in client website, see details here:

https://toolset.com/forums/topic/_post-variables-are-being-destroyed-or-removed-before-hook-can-run/#post-1175768

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This support ticket is created 5 years, 11 months ago. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by benjaminJ-3 5 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1170818

I am trying to: Automatically log in a user like this post: https://toolset.com/forums/topic/automatically-log-in-user-after-created/

Link to a page where the issue can be seen: hidden link

When the form is submitted the post variables must be getting purged or destroyed before the hook runs with the function from this URL: https://toolset.com/forums/topic/automatically-log-in-user-after-created/ can be run.

We created a plugin to dump the $_POST variables (as a test) and nothing is returned from the Toolset User Form. But if we create our own simple form (as seen on the test URL) and post the variables in that then we can output the $_POST variables. It's like Toolset is removing the $_POST variables before they can be grabbed and entered into the function which automatically logs in the user.

#1171114

Hi,

How do you setup the Toolset form for creating user?
Can you take a screenshot for it?

And in case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2019, and test your custom PHP codes again.

#1171280

I can give you login info, how can I submit it?

#1172167

Have you tried as I mentioned above?

And in case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2019, and test your custom PHP codes again.

Can you confirm the compatibility problem?

If there isn't compatibility problem, please provide your website database dump file, also point out the problem page URL and form URL, I need to test it in my localhost. thanks

#1174576

We have tested with all plugins disabled and the error is still there. But you will need the theme files to test this. You can log into the Admin of the development site and download the fresh copy of a Duplicator file I just created.

Link to a page where the issue can be seen: hidden link

#1174938

I have enabled the "private detail box" again, you can put your database dump file in your own google drive disk, and share the link in below private detail box, thanks

#1175499

Did you do anything on the production site that would stop the jonroc-design-center plugin from registraring a template file? I was working on the site last night and everything was fine and today the templates in the plugin are not loading.

#1175768
post.JPG

Thanks for the details, I have added below codes in your theme file "functions.php":

add_action( 'cred_save_data', 'tssupp_cred_autologin', 10, 2 );
function tssupp_cred_autologin( $post_id, $form_data ){
    if ( 18236 == $form_data['id'] ) { // Edit as required
      var_dump($_POST);
      die();
    }
}

Test it in front-end:
hidden link

It works fine, does output the value of variable $_POST, see screenshot post.JPG

It is only a demo for your reference, I suggest you follow our document to use action hook cred_save_data:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

For your new question:
do anything on the production site that would stop the jonroc-design-center plugin from registraring a template file?
It is out the range of Toolset support, I suggest you check it with author of the jonroc-design-center plugin

#1178536

That's so strange, we still can't get the post info to come into the function. It's too bad Toolset does not allow an autologin automatically from its form as this is a common need.

#1178538

My issue still exists but don't have any more time to try and troubleshoot.