frm_after_create_entry Hook
-
I’m using the Lite version of Formidable Form and from everything I have found I should be able to use the frm_after_create_entry hook. I have added a Newsletter field to my user profile page my own plugin. I’m trying to update this field when a user subscribes to the news letter from the website. If they are logged in the user profile is updated.
This is my code but it’s not doing anything.
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.");
}
}
}Can anyone help with this?
Joe
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.