//add email address to email list after membership submission
add_action('frm_after_create_entry', 'add_email_to_list', 30, 2);
function add_email_to_list($entry_id, $form_id){
if($form_id == 2){ //id of the form
if(isset($_POST['item_meta'][29])){ //email field
$email = $_POST['item_meta'][29];
//Random dynamic string of length 5
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
$string = '';
for ($i = 0; $i < $length; $i++) {
$string .= $characters[mt_rand(0, strlen($characters) - 1)];
}
// create entry.
FrmEntry::create(array(
'form_id' => 4,
'item_key' => $string,
'item_meta' => array(34 => $email,),
));
}//isset end
}//end form_id 2
}