Assign an entry when the creator is not connected. My code is not working can you help me please

add_action('gform_after_submission_87', 'submission_form_1', 10, 2);

function submission_form_1($entry, $form) {
    $var = intval($entry[205]);
    $entrees = GFAPI::get_entry($var);
    GFAPI::update_entry_property($entry['id'], 'created_by', $entrees['created_by']);

Hello, picard. I recommend enabling Gravity Forms logging and adding custom logging statements to your code.

First, enable logging:

Next, add some custom logging statements, using the examples here:

Try something like this:

add_action('gform_after_submission_87', 'submission_form_1', 10, 2);
function submission_form_1($entry, $form) {	
    GFCommon::log_debug( __METHOD__ . '(): running.' );
    GFCommon::log_debug( __METHOD__ . '(): The Entry => ' . print_r( $entry, true ) );
    $var = intval($entry[205]);
    GFCommon::log_debug( __METHOD__ . '(): Var is now => ' . print_r( $var, true ) );
    $entrees = GFAPI::get_entry($var);
    GFCommon::log_debug( __METHOD__ . '(): Entrees is now => ' . print_r( $entrees, true ) );
    $result = GFAPI::update_entry_property($entry['id'], 'created_by', $entrees['created_by']);
    GFCommon::log_debug( __METHOD__ . '(): Result of GFAPI call => ' . print_r( $result, true ) );

With the additional logging, you should see which part of the code is not working as expected. Share the link to the log file here if you need assistance determining what is wrong. Thank you.

1 Like

I will try your method and give you feedback.

1 Like


here is the error that is generated when submitting the form

We’ll need to see the Gravity Forms Core log. Can you copy the link from the Forms → Settings → Logging page, and share that here? That is where the extra logging was sent. Thank you.

the log file is not created.
when I enable logging and save changes I get the following error

What version of Gravity Forms is installed currently?

the version is 2.6.9

I’ve never seen that error before with a current version of Gravity Forms.

Be sure you do not have the Gravity Forms logging add-on installed. Logging is built in now.

Try updating to Gravity Forms 2.7 which is available today.

Try disabling and enabling logging on the Forms → Settings → Logging page.

Then try to activate the snippet again. It is possible that the snippet is being loaded before Gravity Forms logging functions are available. If that is the case, you would need to add the function with the logging to your theme or child theme functions.php file.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.