The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Modifying an entry when creating a new user


This Discussion is public


I have a project where users are allowed to "claim" entries from one of the forms on the site by way of a second form. This second form can also be used by new visitors to create accounts at the same time.

This created a problem, because while I could use frm_after_create_entry to handle claims by EXISTING users (by assigning their user ID to a field in the claimed entry), Formidable doesn't seem to process things in the right order for this to work with new users - as far as I can tell, it runs frm_after_create_entry AND then creates the user, so there is no user ID for a process based on frm_after_create_entry to use when it triggers.

However, I realized that WordPress has a trigger of its own for when a user is created, which I was able to use to solve my problem. Heavily commented code below:

// Handle free listings claimed by new users

add_action( 'user_register', 'claim_free_listing_new_user', 10, 1 );

function claim_free_listing_new_user( $user_id ) {

    $claimer_info = get_user_by( 'id', $user_id); // Get WordPress' information about the new user
    $user_email = $claimer_info->user_email; // Get the e-mail address from the returned array of user info
    $entry_claimed = FrmProDisplaysController::get_shortcode(array('id' => 530, 'email' => $user_email)); // Since the user had to enter their e-mail address to create an account, we can get data from their form submission by way of views that return data from the most recent entry from the form in question that included that e-mail address, which was the form submission that triggered this whole process.
    $claim_type = FrmProDisplaysController::get_shortcode(array('id' => 532, 'email' => $user_email)); // More data from the user's form submission. It would have been more efficient to do this via a single view that returned an array, but this isn't going to happen often enough to be a big drain on site resources.

// Check one of our recovered pieces of data to confirm that it is worth continuing (e.g. that they were trying a claim of the type we are handling here)

if($claim_type == "Standard"){
    global $frmdb, $wpdb;
    $wpdb->query("UPDATE dbase_frm_item_metas SET meta_value = $user_id WHERE field_id = 218 and item_id = $entry_claimed AND meta_value = 4"); // Update the database as needed

The user is created on that same hook (frm_after_create_entry) with an order of 30. You should trigger your function after that point so the user would be created.

Discussion closed.