Hello there, I am trying to create a webform that takes as a query parameter someone's full name separated by a space. Once it is submitted I want it to email that person, with their email address defined as their first initial plus their last name @site.com. I made a custom module and the code is below:

 

<?php
function webform_email_generate_webform_submission_presave(Node $node) {
	$full_name = $_GET['name'] ?? '';
	
	//I have a watchdog here that reports what $full_name is and it works perfectly
	if(!empty($full_name)) {
		$parts = explode(' ', trim($full_name));
		if(count($parts) >= 2) {
			$first = strtolower($parts[0]);
			$last = strtolower(end($parts));
			$email = substr($first, 0, 1) . $last . '@site.com';
			
			$node->set('contact_email', $email);
			$node->save();
		}	
	}
}

 

However the lines $node->set('contact_email', $email); (and presumably also $node->save();) are giving me issues, as I gather that is not the way to change the field like that. I get the error "Error: Call to undefined method Node::set()". Also, if anyone has links to documentation where I can read about this, that would also be helpful. Thank you for reading.