1

A freelancer put a MC signup form on my wordpress blog, but it's sending emails to the wrong audience in MC. I can't ask him to fix it - he installed malware on my site (and Upwork refused to help!) I'm hoping somewhere here can help.

This is the code:

<form class="gc-subs-form" action="https://lix-it.us16.list-manage.com/subscribe/post?u=8d28aa75ae6b17fa1658a44f0&amp;id=530c88d153" 
method="post" 
id="mc-embedded-subscribe-form" 
name="mc-embedded-subscribe-form" 
target="_blank" 
novalidate="" 
_lpchecked="1">
    <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="Enter Your Email" required="">
    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
    <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_8d28aa75ae6b17fa1658a44f0_530c88d153" tabindex="-1" value=""></div>
    <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="gc-subs-btn">
</form>

I changed the action="URL" to match the audience I want the emails to go to, but it hasn't changed anything.

I could start again with an MC embedded form but I want to keep the styling I currently have.

Help would be greatly appreciated, thank you.

bhanu
  • 1,730
  • 3
  • 12
  • 30
AlfieLix
  • 11
  • 3
  • Is this the code which you have written or the freelancer wrote ? – bhanu Jul 08 '21 at 09:19
  • This is what the freelancer wrote - I thought I could change the action URL and it would fix it, but the rest is as he wrote it. – AlfieLix Jul 08 '21 at 10:01

1 Answers1

0

You cannot add https://lix-it.us16.list-manage.com/subscribe/post?u=8d28aa75ae6b17fa1658a44f0&amp;id=530c88d153 directly in the action attribute of your form to store result.

I can't write the complete feature, I can show you the way how you can achive this.

Leave the action blank and process the request in your functions.php.

check if submit is subscribe because your form submit name is subscribe. So,

if(isset($_POST['subscribe'])) {
 // Form is submitted. Do Something.
}

Now in this case you will need details of the form. Inside if.

$email = $_POST['email'];

if(isse($email)) {
  // You have email value in $email.
  // Send data to Mailchimp.
}

When it comes to sending the data you can use an API you can use https://github.com/drewm/mailchimp-api package. Install this using composer.

Start by use-ing the class and creating an instance with your API key

$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1'); // find the value in your mailchimp account

Subscribe someone to a list (with a post to the lists/{listID}/members method):

$list_id = 'b1234346'; // Use your list ID.

$result = $MailChimp->post("lists/$list_id/members", [
                'email_address' => 'davy@example.com', // Use $email here. 
                'status'        => 'subscribed',
            ]);

Email should be added to your mailchimp list. You can update user after successful submission.

bhanu
  • 1,730
  • 3
  • 12
  • 30
  • Thank you so much for this - I can't upvote you because my account is new but I would if I could. I don't know if my basic code skills are good enough to implement this but I'll give it a try. – AlfieLix Jul 09 '21 at 08:25
  • Well start with steps. First try to get the email value at the backend. If you get stuck at any point just google about that, if you don't get answer Ask Question here and be specific on what you want help with. Once you have the email learn, how to add composer to your project. Then add the said package Then the using that to add value to your list. Hey as you are the author of this question you can mark it as the answer. This is how you can do it. https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 @AlfieLix – bhanu Jul 09 '21 at 09:00