GravityForm email address layout - gravity-forms-plugin

Case: When a user submits a (Gravity)form and the email is received. Under the address section there is a Map It link, which links to the google maps to the specified address.
Question: How to show this link just for specific forms. It should be something like
if( $form['id'] == '101' ) {
}
But im struggling implementing this. The Map It code is defined in /wp-content/plugins/gravityforms/includes/fieldsclass-gf-field-address.php file. Line 905 //adding map link .
Thank you.

Direct add your link in "notification" area ...

Related

How can I add unsubscribe links to my emails when sending via sendgrid/mail

I'm sending emails using: https://github.com/sendgrid/sendgrid-nodejs/tree/master/packages/mail
I have not been able to find out HOW I can add the Unsubscribe equivalent. This is documented in here: https://sendgrid.com/docs/Classroom/Basics/Marketing_Campaigns/unsubscribe_groups.html#-Using-a-Custom-Unsubscribe-Link
On the website, you just use a shortcode [Unsubscribe], this does not work when sending emails via the sendgrid/mail package.
One tip that would have saved me an hour or two is that:
It's possible to send the following in the api json along with other stuff:
"asm":{
"group_id":123,
"groups_to_display": [123],
}
then the following variables become available to use within the template:
<%asm_group_unsubscribe_raw_url%>
<%asm_preferences_raw_url%>
If you want to keep things simple don't include the following variable as it fiddles with too many things (this wasn't obvious from the documentation so obviously I did so and wasted time :( ):
"tracking_settings": {
"subscription_tracking": {
"enable": true,
"substitution_tag": "[unsubscribe_url]"
}
}
Just use them in their raw format and you shall be fine.
Since you're sending using code, it's a "transactional" type of message. You'll want to either turn on the Subscription Tracking filter at the account level (via [UI](subscription tracking setting) or API), or turn it on as you send the message, as part of the mail/send API call, under tracking_settings.
It's important to note that you can't mix those. If you define anything in the mail/send API call, you'll need to define everything for Subscription Tracking in that call. SendGrid won't look at some settings at the mail level, and some at the account level.
Most users will just set it at the account level. There, you can customize the HTML & Text of the Unsubscribe footer, customize the HTML of the landing page, or redirect landing to a URL of your choosing, which will send the recipient there with ?email=test#domain.com in the URL string for your system to catch. You can also define the "replacement tag" like [%unsubscribe%], so that you can place the URL wherever you want within your HTML.
https://app.sendgrid.com/ > Suppressions > Unsubscribe Groups > Create New Group
Note down group_id/ids. e.g 123 (Only number !Not string)
Send email using node.js
const sgMail = require('#sendgrid/mail');
sgMail.setApiKey(SENDGRID_API_KEY);
const tags = { invitedBy : Alex }
const msg = {
to: email,
from: { "email": SENDER_EMAIL,
"name": SENDER_NAME
},
templateId: TEMPLATE_ID,
dynamic_template_data: {
Sender_Name: name,
...tags
},
asm: {
group_id: 123,
groups_to_display: [
123
],
},
};
await sgMail.send(msg);
The best approach is to use Group Unsubscribes.
First create a group in Sendgrid:
Groups > Unsubscribe Groups > Create a group
Next, insert a module into the Sendgrid template that creates specific tags in your email, which are populated when you make an API request
Go to your template
Insert an unsubscribe module in an HTML block
Save
Finally make an API request and specify the group created in step 1:
"asm":{
"group_id":544,
"groups_to_display": [544, 788],
}
These will be inserted into the module mentioned in step 2 when the email is sent.
Unfortunately Sendgrid unsubscribe links are not as straightforward as they could be. They are explained in more detail here
The easiest way is to do this via the SendGrid GUI.
Go to Settings -> Tracking -> Subscription Tracking

override the content of cakePHP3 emails

I have built a cakePHP3 application and I'm looking for some advice concerning the following situation. An e-mail configuration is setup as follows, to send a mail whenever a new order has been created.
public function orderCreated($order, array $attachments = [])
{
$email = $this
->locale($order->customer->language)
->to($order->customer->email)
->from(Configure::read('Webshop.email'), Configure::read('Webshop.name'))
->subject(__('Confirmation of your order {0}', $order->nr))
->template('orders' . DS . 'order_created')
->set(['order' => $order])
->attachments($attachments);
return $email;
}
Has worked perfectly fine for ages, but I'd like to add some new functionality to this specific e-mail (and others). Admins should be able to override the content of the orders/order_created.ctp template if they want to, so they can define the content of this e-mail theirselves. So they don't have to rely on the same content in the order_created.ctp template I did provide.
Creating a UI for saving their own e-mails is not the issue. But the issue I don't really know how I could provide the overrided content to the cakePHP3 mailer. I tried setting
->template(false)
->message($new_content)
But that didn't help. Message doesn't reach mailbox because the body is empty.
Thanks.
I think I'd go with something like this:
->template('orders' . DS . 'order_created_custom')
->set(['order' => $order, 'content' => $new_content])
And then in the new order_created_custom.ctp you would output the $content. This gives you the option to do some text replacements on the content based on the $order, as well as perhaps having things like a standard salutation or signature.

Google Spreadsheet Email If

First, I am a complete beginner and have no idea what I am doing.
I am wanting to take a form that is submitted in Google forms and email the data to certain individuals. I got an example code from http://www.labnol.org/internet/google-docs-email-form/20884.
I changed the email and I got this to work. However now I would like to add a simple if statement so that depending on the first question in the from Who would you like to contact? it will send the email to different email address per different answer. Note: there are more than two choices so I imagine I will need more than one else statement.
I think I need something like this, but I am not sure how to make it work.
if(e.parameter.source == "Info") sendto = "bob#yahoo.com" else sendto = "bob#email.com"
Thanks in advance
Add the if else block where "source" is the name of the form field:
var email = Session.getActiveUser().getEmail();
if(e.parameter.source == "Info")
email = "bob#yahoo.com"
else if (e.parameter.source == "Info2")
email = "bob2#email.com"
else
email = "bob2#email.com"

Drupal 7 - Creating dependent autocomplete form fields

I'm wondering if anyone can assist me in updating the code detailed here (http://oif.eafarris.com/blog/pre-fill-cck-node-fields-based-on-a-node-re...) for Drupal 7. The function described in that post is identical to what I'm looking to do on my Drupal 7 site but I'm not well versed enough programmatically to do it myself.
I have a content type Event. On the node creation form for Event, I have an autocomplete field for "Client". Below that are additional fields for name, address, etc. The end result I'm hoping to achieve here is:
User enters client name in the autocomplete Client field.
Entered client name matches an existing client and is selected.
Using the node ID of the selected client, the address fields are then populated automatically.
I have a JSON view with a nid argument which spits out the required fields at the url http://domain.com/json-clients/[nid]. But I am unable to get that info returned to the correct fields on the form.
Below is the code as I've got it modified trying to get it to work with D7. Anyone see the glaring errors and care to assist?
(function ($) {
Drupal.behaviors.sponsorhelper = function () {
$("input[name='field_client[und][0][nid]']").blur(function() {
nidRegEx = /\[nid:(\d+)\]/;
SponsorHelper.fill($(this).attr('value').match(nidRegEx)[1]);
})
};
SponsorHelper.fill = function(nid) {
var url = Drupal.settings.basePath + 'json-clients/' + nid;
jQuery.getJSON(url, function (data, result) {
if (result != 'success') {
return;
}
$("input[name='field_address_1[und][0][value]']")
.attr('value',data.nodes[0].node.field_address_1_value);
$("input[name='field_address_2[und][0][value]']")
.attr('value',data.nodes[0].node.field_address_2_value);
})
};
})(jQuery);
Any help is greatly appreciated.
Thanks.
Instead of writing your own javascript try handling this with a couple of drupal's community modules. Check out:
http://drupal.org/project/conditional_fields
http://drupal.org/project/computed_field/
You can us conditional fields to hide the address until the client info is put in. Then use computed fields to search for the client and auto fill the address fields.

Drupal get site wide email address?

In my module I want to get the site wide email address - the one that is set in the site information admin pages and that is used for all automatically send email messages.
How can I do this?
$site_email = variable_get('site_mail', '');
In Drupal 8:
$site_mail = \Drupal::config('system.site')->get('mail');
Looking into the system module, I found the settings form references the following:
variable_get('site_mail', ini_get('sendmail_from'));
You can get more ideas with this link
variable_get('site_mail', ini_get('sendmail_from'));
You can preprocess the variable like -
function hook_preprocess(&$variables, $hook) {
$variables['site_email'] = \Drupal::config('system.site')->get('mail');
//kint( $variables['site_email']);
}
then use $variables['site_email'] anywhere to get the system wide email.