Cannot redeclare function [RESOLVED]

Greatly appreciate assistance in advance and a happy festive season to all.

I get a “Cannot redeclare function” message, understanding that you can’t redeclare a function. This is the code I currentl have:

/**
*SUPPORT OPTION 1
*/
add_filter( 'gform_user_registration_update_user_id_23', 'override_user_id', 10, 4 );
function override_user_id( $user_id, $entry, $form, $feed ) {
    // Get email address from URL query string on form display or field ID 1 during submission.
    $email = rgar( $entry, '2', rgget( 'the_URL_param_here' ) );
 
    return email_exists( $email );
}

/**
*SUPPORT OPTION 2
*/
add_filter( 'gform_user_registration_update_user_id_16', 'override_user_id', 10, 4 );
function override_user_id( $user_id, $entry, $form, $feed ) {
    // Get email address from URL query string on form display or field ID 1 during submission.
    $email = rgar( $entry, '72', rgget( 'the_URL_param_here' ) );
 
    return email_exists( $email );
}

/**
*SUPPORT OPTION 3
*/
add_filter( 'gform_user_registration_update_user_id_21', 'override_user_id', 10, 4 );
function override_user_id( $user_id, $entry, $form, $feed ) {
    // Get email address from URL query string on form display or field ID 1 during submission.
    $email = rgar( $entry, '36', rgget( 'the_URL_param_here' ) );
 
    return email_exists( $email );
}

Sincerely
Emin

You are declaring a function named override_user_id three times in the code, if you want to use your code as is you’ll need to rename two instances of that function to something unique. e.g.

/**
*SUPPORT OPTION 1
*/
add_filter( 'gform_user_registration_update_user_id_23', 'override_user_id', 10, 4 );
function override_user_id( $user_id, $entry, $form, $feed ) {
    // Get email address from URL query string on form display or field ID 1 during submission.
    $email = rgar( $entry, '2', rgget( 'the_URL_param_here' ) );
 
    return email_exists( $email );
}

/**
*SUPPORT OPTION 2
*/
add_filter( 'gform_user_registration_update_user_id_16', 'override_user_id2', 10, 4 );
function override_user_id2( $user_id, $entry, $form, $feed ) {
    // Get email address from URL query string on form display or field ID 1 during submission.
    $email = rgar( $entry, '72', rgget( 'the_URL_param_here' ) );
 
    return email_exists( $email );
}

/**
*SUPPORT OPTION 3
*/
add_filter( 'gform_user_registration_update_user_id_21', 'override_user_id3', 10, 4 );
function override_user_id3( $user_id, $entry, $form, $feed ) {
    // Get email address from URL query string on form display or field ID 1 during submission.
    $email = rgar( $entry, '36', rgget( 'the_URL_param_here' ) );
 
    return email_exists( $email );
}
1 Like

Thank you Karl, you’re a gem!

1 Like

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