Can anyone help with this?add_action(\'frm_after_create_entry\', \'joepotgieter_add_entry_id_to_user\', 30, 2);
function joepotgieter_add_entry_id_to_user($form_id) {
if ($form_id == 3) { // my Newsletter form id
// Check if the user is logged in
if (is_user_logged_in()) {
$user_id = get_current_user_id();
error_log(\"User ID: \" . $user_id);
// Update the user meta field
$updated = update_user_meta($user_id, \'newsletter_field\', \'on\');
// Log success or failure
if ($updated) {
error_log(\"Successfully updated user meta for user ID: \" . $user_id);
} else {
error_log(\"Failed to update user meta for user ID: \" . $user_id);
}
} else { //Dont actually care about this as the form sends an email
error_log(\"User is not logged in.\");
}
}
}
Joe
Hi Rob,
The field is created in another function before in the user's profile. The user I'm testing with has had this field for a while. I can check and uncheck it on the user profile page and it updates the database. Running the above code should (in my understanding) run after the Formidable form (3) has completed. The database is not not updated so I can only assume it's not running. I'm working on a "staging" site and the owners will not give me access to ssh or ftp so I can't view the logs. They claim none of my error_log items are in the error.log.
This is frustrating as you can see my hands are tied on debugging this.
Is this hook available on the Lite version?
Joe
It sounds like you want frm_after_update_entry, which fires when an entry is updated, rather than created. Once it's created frm_after_create_entry will never be called again.
I'll give that a shot. Thanks.
Please login or Register to submit your answer