How to add php script to forward a copy of a form - joomla

Currently using Joomlashine JSN Uniforms on a beta site. I need to send a duplicate submission to another email address. However, JSN Uniforms canot do this ATM, but there is Script section in form admin panel which includes
Custom Scripts (PHP) called on form processing
The $html string contains the HTML code of the form. You can modify it by adding a PHP script below. Remember to not include the tags.
On form Process
The $post variable contains $_POST data of the form. You can modify it by adding a PHP script below, before it is added to the database. Remember to not include the tags.
After form has been processed
The $post variable contains $_POST data of the form. You can modify it by adding a PHP script below, after form been processed successfully. Remember to not include the tags.
Form Setup
Name
email
subject
department (pulldown) 1. Sales & Service 2. Training & Standards
Message
send
Department: Sales & Service has 2 email addresses (at the moment Uniforms can only assign 1 email address
user1#company.com
user2#companny.com
is there a script I can use to have the submitted form send to the Department user2#company.com and have the form sent to user1#company.com

problem resolved by not messing around with Joomla but adjusting the email service to forward/alias to one address and simply setup Outlook client for each use for the primary email address

Related

Pre-filling a hosted MailChimp signup form with an email address shows validation errors

We're trying to pre-fill the email address field of a hosted MailChimp form. Here's the blog post that talks about exactly this matter: https://blog.mailchimp.com/how-to-pre-fill-items-on-your-mailchimp-hosted-form/.
So here's our Newsletter signup form without any validation errors:
https://camping.us2.list-manage.com/subscribe/post?u=761a52bbd46ab21474b3af314&id=5cc638b5e6.
The problem arises when I add an email address to the URL as the value for the first form field, MERGE0, like this (url-encoding the email address, so # becomes %40):
https://camping.us2.list-manage.com/subscribe/post?u=761a52bbd46ab21474b3af314&id=5cc638b5e6&MERGE0=test%40camping.info.
Now, the form correctly copies the email address into the input field with name MERGE0 but it also displays three validation error messages:
Note: the email address field is mandatory.
When I try to pre-fill the user's first or last name fields adding MERGE1=John or MERGE2=Doe to the form's url, all is well - no error happens. It seems to be a problem with mandatory fields.
I'm arguing that this is a problem on MailChimp's side but they refuse to help saying that this is custom code and none of their business.
Can anybody help fix these errors?
It turned out that the problem was caused by a mistake in the URL.
Instead of camping.us2.list-manage.com/subscribe/POST?u=761a52bbd46ab...
it had to be camping.us2.list-manage.com/subscribe?u=761a52bbd46ab...
And the errors were gone!
This really made sense in the end, because posting the form should actually trigger the validation.

Is it possible to use nested merge tags in Mandrill?

Is it possible to use nested merge tags?
What we need is to be able to define the UNSUB tag depending on the values from other merge tags, like on this example:
<a
href="*|UNSUB:*|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all|*">
Unsubscribe
</a>
Is this correct?
Should be done in a different way?
It's not currently possible to nest merge tags. In this case, your best bet would be to add your own List-Unsubscribe headers (using the headers parameter in the API) and pass either your own URL, or a URL constructed with your merge tags but not the UNSUB merge tag.
From the API:
What happens when the [unsubscribe] link is clicked?
If a recipient clicks the generated link, the message status is changed to Unsubscribed and > the recipient's address is added to the Rejection Blacklist in your
Mandrill account. The redirect URL will be appended to include two
querystring parameters that can be used for processing the unsubscribe
in your own system or database:
md_id - the _id, as provided in the API call and webhooks of the
specific message where the unsubscribe link was clicked
md_email - a URL-encoded version of the recipient's email address
So you don't have to worry about generating an unsubscribe url for every user. Just put a generic url and mandrill automatically will append to you the email of that user in the md_email variable.
The documentation suggest that you do this then:
Click here to unsubscribe.
And mandrill will append the correct user email and id:
http://mywebsite.com/unsub?md_email=fulanito#gmail.com&m_id=23321
Since mandrill doesn't support nested merge tags, here is the solution for the case like yours if you dont mind after user click unsub, it did't go to mandrill's black list, since the unsubsription are all handled by your app.
PER YOUR CASE:
Manually compose your unsubscribe link
e.g.
*|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all/
At the end of your link, append the mandrill recipient email var.email=*|EMAIL|* e.g.
*|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all/?email=*|EMAIL|*
Put the link to your mandrill template
Unsubscribe Me
reference: mandrill doc

JMeter - how to simulate an email address AND a confirm email address

I'm trying to setup a JMeter test plan and need to create unique email addresses for submission. I saw this that suggested using the Random Function.
The problem is that I need to generate an email address AND reference that same created email in the confirm_email field. I need to randomly generate an email address and then use it twice. How do I do that?
Thanks.
I learned that there's an extra parameter to the __Random function that can hold a variable name that you can reference later.
So, my Parameters are:
email : ${__Random(1,10000000,refName)}#jmeter.com
email 2 : ${refName}#jmeter.com
Voila!

Using customer first name in order confirmation email

I've seen a bunch of articles (mostly 3-5 years old) detailing various methods of getting the customer's first name into the order confirmation email but I just get either a blank, or unparsed PHP.
For example this:
<?php echo $this->__('Hello, %s', Mage::getSingleton('customer/session')->getCustomer()->getFirstname()); ?>
Renders in the email like this:
__('Hello, %s', Mage::getSingleton('customer/session')->getCustomer()->getFirstname()); ?>
Could somebody point me in the right direction? This is on Community Edition 1.7.
Thanks
[EDITED] You can't use PHP code in your email-templates directly. If you want to insert dynamic data into your email-templates, you have two possibilities:
a) In every transactional email you can access the methods of the model, which is in charge for the transactional email, it is: for mails dealing with orders, this is the order-Model, for mails dealing with newsletters, this is the newsletter-model and so on. You can access the methods with the syntax:
{{var model.method()}}
So, in your case, to access the customer's first name in an order confirmation email, you need to look for a suiting method in the order Model, which is getCustomerFirstname() .
Then you can call it, following the given syntax:
{{var order.getCustomerFirstname()}}
b) You can include dynamic data into your email-template by creating a custom phtml-template and including it into your email-template via the {{block}} directive (as pointed out by benmarks in the comment below)

Send a POST ajax to add products to quotation

My background is more server-side than front-end. So I may be lacking in some basic front-end knowledge.
I have a endpoint called
/quotations/:id/products
which if you do a POST action, this means you want to add products to the specified quotation where :id represents the quotation id.
In my schema, quotations and products have a many-to-many relationship.
The endpoint also expects the data is sent in the form of products[].
Meaning to say, if I want to add products with id 2, 7, and 154 to the quotation 3
I am POSTING
<input name="products[]" value="2" />
<input name="products[]" value="7" />
<input name="products[]" value="154" />
to the url /quotations/3/products
My question is how do I create the Model and View using Backbone for this setup?
I bought Addy Osmani's book on Developing Backbone.js Applications. So I have setup my backbone similar to his example.
There is only an example of a straight forward add model.
Hopefully I get an answer that follows the convention that Osmani sets out for adding children to a parent type of behavior.
Osmani also mentioned about Backbone Relational.
I am not sure if I should use this or even how. I have read the documentation, but I am not sure how to fit this into the way Osmani has structured his Backbone example apps.
UPDATE:
If it is a success, I want the page to redirect to another page called /success.
If it is a failure, I want the page to display a failure message somewhere. Assume there is a <div id="message"></div> for me to update.
In other words, for failure, the page stays as a single page app.
For success, the page goes to another page.
As for server-side code for returning JSON replies etc, I can do this without any problems. Assume I use PHP.
I faced a similar problem recently, I can't tell your for certain this is the best way to do it but it's the way i've found to work reliably. I tried BackboneRelational but was having troubles with it.
This assumes you will need to create the Quote object & ProductQuotation in 1 step.
Set up a view for New Quote
On initialization of this view:
A) Create a new empty Quote model
B) Create a new collection for ProductQuotes
C) Create a new ProductQuote view for each ProductQuote you're adding
D) Subscribe the Quote view to a custom Backbones event binding (Backbone JS: can one view trigger updates in other views?), i.e.
Backbone.pubSub.on('quote_new-product-save', this.AddProduct, this)
This view will now call AddProduct any time you trigger this event.
On initializing each ProductQuote view create a new Product model
Wire this view up for your user to fill in any applicable information & when they are done set this information to that views Product model & trigger the "quote_new-product-save" event mentioned above and pass it that product model.
Back in the Quote view, AddProduct will automatically be called as it was binded to this event. You should wire this to receive the new Product model & add it to the ProductQuotes collection.
So now you have your Product model data set to your ProductQuotes collection but this is still not directly linked to the current Quote (which still hasn't been saved) so set the 'order_items' attribute on your model to all models in your ProductQuote collection i.e.
this.model.set('product_quotes', this.collection.models)
Now your unsaved Quote model will have all members of your ProductQuotes collection set as an attribute.
Now you'll need to call save on the Quote model & send the data to the server. Things to keep in mind here is that your urlRoot is set properly & that the data being sent to the server is being properly formatted. I recommend reading Saving nested objects with Rails, backbone.js, and accepts_nested_attributes_for about overriding the toJSON method in your Quote model.

Resources