Categories
technical

Use Webhook from Mailpoet when a new subscriber is added

Took a bit of trial and error to get this code to work. Definitely not perfect, as I am using the subscriber id to get the subscriber email and then sending it…

Basically, just replace the URL for $webhook_url.

You can put this within a plugin or functions.php in order to work. However, it may get overwritten when wp or a plugin updates so better to create one on your own.

 

<?
function send_webhook_on_new_subscriber($subscriber_id) {
// The URL of your webhook receiver
$webhook_url = ‘Put URL Here’;

// Check if MailPoet API class exists
if (!class_exists(\MailPoet\API\API::class)) {
error_log(‘MailPoet API class does not exist.’);
return;
}

// Get MailPoet API instance
$mailpoet_api = \MailPoet\API\API::MP(‘v1’);

// Try to fetch subscriber details using the API
try {
// Now, we’ll fetch subscriber data using the subscriber ID
$subscriber_data = $mailpoet_api->getSubscriber($subscriber_id);

// Send the entire subscriber data to the webhook
wp_remote_post($webhook_url, array(
‘body’ => json_encode($subscriber_data),
‘headers’ => array(‘Content-Type’ => ‘application/json’),
));

} catch (\Exception $e) {
error_log(‘Failed to fetch subscriber details using MailPoet API: ‘ . $e->getMessage());
}
}

add_action(‘mailpoet_subscriber_created’, ‘send_webhook_on_new_subscriber’);

?>

Categories
technical

[Fix] Google Search Console: Page isn’t usable on mobile

 

Error message telling me my page is not usable on mobile.

If you have spent the last few hours/day/weeks/months trying to fix the Google Search Console message that your WordPress page isn’t usable on mobile, then you have hopefully come to the correct place to fix it.

The classic message says:

Why it’s not usable

Content wider than screen

Clickable elements too close together

Text too small to read

And when you know that this just isn’t true, it’s extremely frustrating.

There are many on the internet who say just to ignore it, if you know that your page is showing, but I’m not in that school as I don’t like to give Google even a chance to reduce my rankings and if mobile usability has an effect on my rankings then that is not a good thing.

At the end of the day, the message isn’t appearing there for no reason. So why doesn’t Google see the page as usable even if it looks fine to me and every single mobile and screen-tester that I look at. Even on the screenshot that Google shows you of your site, it still looks good!

So, realize that if there is any chance that what Google says is true then fix that first. Hopefully that goes without saying.

The next thing to do and this is BIG is to see if you are getting javascript errors according to the Google Search Console.

When you click on View Crawled page, or View Tested page it should show you.

Especially look at the Javascript console messages and page resources. If things aren’t being loaded, then this could change the way that Google is looking at your page. The fix for this is to turn off javascript in your browser and see if you can find the error.

How I Fixed It

So, here is how I fixed it. Quite possibly not the reason why you have the error but definitely worth it as it fixed it for me. I am using Elementor which may or may not have something to do with it. I also have created some pages in the Classic editor rather than the block editor.

What I did, was to convert the post to be edited with Gutenberg rather than Elementor or Classic Editor.

The way to do this is simply open the post in block editor and find a setting where you can convert it to blocks. Mine was on the left hand side. Make sure that you save it after. If this doesn’t work then try opening it in block editor and then saving it after. Make sure that you clear your cache and test again.

If you are trying to do multiple pages, or can’t find out how to do the above, then you can use a plugin called Bulk Block Converter. I was able to convert 100s of posts at a time without having to open each post.

If for any reason, this still doesn’t work, but you feel you are upon the right track (ie. you didn’t use block editor to create the post), then make sure that the cache is cleared so that Google is seeing the latest version of your site. One way to achieve this may be just to make a small edit on the post itself and update it.

Categories
technical

Using Aweber and Zapier Errors

Sometimes the most simple of tasks can also be the most annoying and tedious. Something that should take about a minute can go into hours.

A previous boss, Charlie, told me that if you are having a technical problem, then someone else has already had the same problem and you will find a solution using Google.

He was wrong in this case, but after I write about it here, he will be correct…see what I did there?!

Here is what I wanted to do:

When someone subscribes to a list on aWeber, Zapier will then be used to connect to Clearout. Clearout will check if it is a valid email and if so, will do nothing. If it is not, then Clearout will tell aWeber to unsubscribe.

How the zap looks. Note that I used only continue if the result contains the text invalid.

Nothing particularly complicated, but didn’t work 🙁 and got an error message that meant very little. After a search, it seemed to mean that you can not add a lead to AWeber unless the settings on that list allow someone to be subscribed without confirming.

That shouldn’t be the case here, because I wasn’t trying to subscribe someone, but unsubscribe someone.

Also, shouldn’t have been a problem because I already enabled single-optin to this least.

Make sure that API double confirmation is also switched off.

There was a suggestion on a forum to search by id rather than email address. Same error.

Final solution was to change a setting under list settings so that double optin was disabled both for the form and admin AND also for the API.

ON another note, it really should be so hard to achieve what I was trying to and a direct integration really would make far more sense. Would also mean that I could actually ‘clearout’ a whole list in aweber that already exists rather than just when a new subscriber is added.

And for this to take 3 tasks in Zapier also seems a bit of an overkill…