get_fields() : ( isset( $record->form_data ) ? $record->form_data : array() ); $email = ''; $user_id = 0; $hash = ''; if ( $fields && is_array( $fields ) ) { foreach( $fields as $key => $value ) { if ( 'email' === $key ) { $email = $value; } } } if ( $email ) { $hash = $this->get_rand_hash($email); $user = get_user_by('email', $email ); if ( $user ) { $user_id = $user->ID; } // Insert the data into the database table global $wpdb; $table_name = $wpdb->prefix . 'wpfnl_optin_entries'; $wpdb->insert($table_name, array( 'funnel_id' => $funnel_id, 'step_id' => $step_id, 'user_id' => $user_id, 'email' => $email, 'hash' => $hash, 'data' => serialize($post_data), 'date_created' => current_time('mysql'), )); } } /** * Returns alphanumeric hash * * @param $email * @param $len * @return string * * @since 3.5.0 */ public function get_rand_hash( $email, $len = 32 ) { return substr( md5( $email ), -$len ); } }