Hey @luxman007,
I believe the following code should help:
function slicewp_custom_register_affiliate( $entry, $form ) {
if ( $form['id'] !== 123 ) {
return;
}
$affiliate = slicewp_get_affiliate_by_user_id( get_current_user_id() );
if ( ! is_null( $affiliate ) ) {
return;
}
$affiliate_data = array(
'user_id' => get_current_user_id(),
'date_created' => slicewp_mysql_gmdate(),
'date_modified' => slicewp_mysql_gmdate(),
'status' => 'active'
);
$affiliate_id = slicewp_insert_affiliate( $affiliate_data );
if ( $affiliate_id ) {
do_action( 'slicewp_register_affiliate', $affiliate_id );
}
}
add_action( 'gform_entry_created', 'slicewp_custom_register_affiliate', 10, 2 );
The code will check for new entries from the form that has the ID 123 (please change the ID to the actual one from Gravity Forms).
If the user is logged-in and is not registered as an affiliate, they will be added as an affiliate with the “active” status. If you wish to review each application, please change “active” to “pending” in the code.
Also, please note that you may have data missing from their affiliate accounts (such as the payment email and reason for signing up for your affiliate program), considering that the form has no data.
Alternatively, what you could also do, instead of adding this empty Gravity Forms form, you could add the affiliate registration form (described here: https://slicewp.com/docs/adding-affiliate-registration-page/) as the extra step after they complete the initial form you already have set up to filter them. I’m not sure if this makes sense, as I don’t know your setup, but you could try it to see how it works.
Thank you and best wishes,
Mihai