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.
Recent comments
The problem here is that the Rule itself is faulty. See explanations and an alternative here: https://github.com/backdrop-contrib/rules/issues/241
Rules and Registration: "Undefined method AnonymousUser::save()"
I believe you can accomplish at least some of that functionality using Rules module. You can Grant, Reset and Revoke permissions based on many trigger events such as Saving a Node or...
Workflow module or equivalent?
Hi Mike, try user/login, that should work.
Admin login - help
I wrote a blog post a while back about how the color module works, in case that is helpful. https://www.triplo.co/blog/color-module-backdrop-cms
Color module aggressive search and replace custom css color values
You are asking this question at the right time. Work has been done on the Content Moderation module for Backdrop CMS, but it's still not working fully. We would welcome help getting this...
Workflow module or equivalent?