• Resolved jawadakr

    (@jawadakr)


    Hi There

    anyone know how to capture pop up form submitted data. I am saving data in local list but I also want to save the user submitted information in another plugin as well and so far I am unable to find any hook or action call on the documentation which can help to achieve this.

    Their should be some hook like on submit or on entry added in the code some where.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Adam – WPMU DEV Support

    (@wpmudev-support8)

    Hi @jawadakr

    I hope you’re well today and thank you for your question!

    I think that should be doable as it would be similar to the way built-in integrations are created but I admit I’m not sure about details. I’ve passed it on to our developers and I’m waiting for their feedback on this.

    Please stay tuned. We’ll update you here as soon as we get to know more about possible solutions.

    Best regards,
    Adam

    Plugin Support Adam – WPMU DEV Support

    (@wpmudev-support8)

    Hi @jawadakr

    I just got response from our developers and the good news is you just need a small piece of code. I have tested it on my own setup and it intercepts the form data nicely:

    add_action( 'hustle_form_after_handle_submit', function( $module_id, $response ){
    	if ( ! isset( $response[ 'success' ] ) || empty( $response[ 'success' ] ) ) {
    		return;
    	}
    	$data = filter_input( INPUT_POST, 'data', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
    	parse_str( $data['form'], $form_data );
    	
    	error_log( print_r( $form_data, true ) );
    	
    	
    }, 20, 2 );

    This snippet would print out all the form data to the debug.log file if debugging (with DEBUG_LOG) is enabled but to use it for other purposes you’d just want to replace this line

    error_log( print_r( $form_data, true ) );

    with a call to your own function that would do whatever you need to be done with form data. The $form_data variable is an array that stores all the fields values of the submitted form.

    I hope that helps 🙂

    Best regards,
    Adam

    Thread Starter jawadakr

    (@jawadakr)

    Hi Adam

    Thanks. That worked very well for me.

    Hi Adam,
    Good answer, I was looking for the same hook.
    Worked perfectly.
    Thank you!

    There is a redundant condition here, in PHP a variable is considered empty if it does not exist:

    
    if ( ! isset( $response[ 'success' ] ) || empty( $response[ 'success' ] ) ) {
    

    This would be the same but slightly faster:

    
    if ( empty( $response[ 'success' ] ) ) {
    
    Plugin Support Adam – WPMU DEV Support

    (@wpmudev-support8)

    Hi @baras

    I’m glad it helped you too!

    As for “There is a redundant condition here, in PHP a variable is considered empty if it does not exist:” – yes, that’s “functionally” true but there’s a small “catch”. This “redundancy” here is pretty much only to make sure that no warnings will be triggered in case of unexpected issues which might cause the variable to actually exist but be empty. That’d be rare case and “functionally” would indeed be the same but on some setups (I’m not that good, I’m not sure why but I believe it’s related to PHP version/errror reporting settings) it would log a warning. I’ve seen that myself actually 🙂

    Still though – your version would work exactly the same way and yes, it would be slightly faster (probably not “measurably” faster but faster) so it’s perfectly fine 🙂

    Best regards,
    Adam

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to capture user form entry data’ is closed to new replies.