Hello there,
I’m having trouble with a form designed to create users. I use the Register Users Add-on and in this form I have a multiple checkbox field corresponding to an ACF checbox field.
The data saved in the database is a comma separated string: C1, C2, C3…
I need it to be serialized but my function does not work…
Can’t figure out what the data from the form on user activation looks like?
Here is my code:
add_action( 'gform_user_registered', 'waw_add_user_cours', 10, 3 );
function waw_add_user_cours( $user_id, $feed, $entry ) {
// Form Field ID
$cours = rgar( $entry, '17' );
if ( $cours ) {
// Convert the comma separated string to an array.
$cours_array = explode( ', ', $cours );
// Serialize the array for ACF.
$cours_serialized = maybe_serialize( $cours_array );
// Update user meta.
update_user_meta( $user_id, 'les_cours', $cours_serialized);
if ( true === WP_DEBUG ) {
error_log( print_r( $cours, true ) );
}
}
}
In debug.log, $cours is empty…