• Hello,

    I have to get a temporary token to submit the form data to the API (Filemaker Data API). I have a working function to get the token and I’d like to include it, but I don’t know in which php-file. I think, it should be after the user clicks the submit button. Can somebody help me out, please?

    Or do you see another opportunity to request the token from the data api each time a user clicks the submit button?

    PS PHP and WordPress are relatively new to me.

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter jhofmann

    (@jhofmann)

    So I think, I’m a few steps further:

    I added the function as a plugin. It should be triggered by this in submission.php:

    private function before_send_mail() {
    $abort = false;

    do_action_ref_array( ‘wpcf7_before_send_mail’, array(
    $this->contact_form,
    &$abort,
    $this,
    ) );

    return ! $abort;
    }

    my index.php in my plugin-directory looks like:

    <?php
    /*

    Plugin Name: Get Filemaker token

    Plugin URI:

    Description:

    Author: myself

    Version: 1.0

    Author URI:

    */

    add_action(“wpcf7_before_send_mail”, “wpcf7_get_fmToken”, 10, 3);

    function wpcf7_get_fmToken ($WPCF7_ContactForm) {

    //just for testing write into file
    $jhFile = ‘test.txt’;

    if ( file_exists( $jhFile ) ) {
    $file = fopen( $jhFile, ‘a’ );
    } else {
    $file = fopen( $jhFile, ‘w’ );
    }
    fwrite( $file, “Function has been triggered\n” );

    fclose($file);

    }

    ?>

    But it doesn’t work even with full rights on files and plugin directory.

    These rights are sufficient, aren’t they?
    Plugin directory: 755
    Plugin index.php: 755
    test.txt: 775

    Has anyone any ideas? For this I would be very grateful.

    Best regards

Viewing 1 replies (of 1 total)
  • The topic ‘build in a function to get token’ is closed to new replies.