Automatically Assigning Users with the WordPress Importer

Recently, one of our clients enlisted our help with migrating thousands of WordPress posts to another server. At 515 Media, we like to use the official WordPress Importer plugin for such assignments – it reliably preserves all content formatting, and works perfectly in tandem with WordPress’ native XML generator.

Here’s the problem…

As much as we like the WordPress Importer, we ran into a frustrating limitation of the software this time around. You see, our client’s posts were authored by nearly 300 different user accounts, and the WordPress Importer tool did not automatically map these accounts to our new database.

Instead, the plugin will prompt you to create associations for each user by hand:

As you can imagine, this is quite a laborious process if you’re dealing with a database containing dozens or hundreds of published users! Our hearts go out to those of you who have had to map this many fields by hand – we’ve definitely been there before!

That’s why we came up with a simple JavaScript-based solution to completely automate the user assignment process. Today, we would like to share our code with all of you:

Our solution

// ==UserScript==
// @name         Import WordPress - Auto Assign Authors
// @namespace    https://515.media
// @version      0.1
// @description  Quickly fill out post authors
// @author       Eric Black of 515 Media
// @include       */wp-admin/admin.php?import=wordpress*
// @grant        none
// ==/UserScript==
var $ = window.jQuery;
$(document).ready(function() {
    $("#authors").before("<input type='button' id='auto-assign-authors' value='Automatically assign authors'>");
    $("#auto-assign-authors").click(function() {
        var missing = 0;
        $("#authors > li").each(function() {
            var full_author = $("strong",this).text();
            var this_author = full_author.substr(0, full_author.indexOf(' ('));
            var is_missing = true;
            $("select option",this).each(function(){
                if ($(this).text() == this_author) {
                    $(this).attr('selected', true);
                    is_missing = false;
                    return false;
                }
            });
            if (is_missing) missing++;
        });
        $("#auto-assign-authors").after("<p>Finished! Total fields without matches: " + missing + "</p>");
    });
});

 

You may install our code to any major web browser with an extension that manages userscripts. We recommend TamperMonkey for this purpose (Firefox / Chrome).

Simply choose to “Create a New Script” and paste our code into the TamperMonkey editor.

The next time WordPress Importer prompts you for user assignment, you will find a new button at the top of the page to fully automate the procedure:

In a matter of seconds, our script will populate every field without any further input.

Plus, in the event that some of your database’s usernames don’t quite match those from your imported XML, our script will tell you how many fields are still blank after the operation is complete (# of unmatched fields.)

You are more than welcome to use this script for free and adapt it to your needs. (We only ask that you don’t claim it as your own or try to profit from it!)

If you have any questions about the installation process or general usage, feel free to get in touch with us today. Also, don’t forget to check out our managed hosting plans if you want our help developing custom scripts for your own projects!

Why Sourcing Your Images Carefully is Critical to Your Business Survival

You’ve probably heard some of the horror stories by now. And if you haven’t, we are happy to share some of ours:

  • Several months ago a client of ours let me know that she was being sued to the tune of 5-figures for using copyrighted images on her blog.
  • A long-time colleague of ours worked with a company who was being brought to court over the background of his website coming from Google Images.
  • A friend of mine mentioned that he was getting a cease and desist letter and a notice of copyright infringement to take an audio track off his website that he thought was open-source. At least in his case he wasn’t getting sued yet.

The stories above are all true, and are a showcase of the challenging times in which website owners live. In these instances we had no knowledge of our clients’ image-sourcing practices. This is also the case with our current client-base – we do not have control over which images our clients choose to use on their website. However, in an effort to be helpful to minimize the odds of this happening to you, we’ve put together a helpful and simple guide on how to effectively source images for your websites and media.

It is important to note that when we design a website, we always strive to use images that come from open-source, free to use and from non-copyrighted catalogues. We do everything in our power to help absolve our clients of liability. However, if you are selecting images to use for your blog, please read on to make sure that you are sourcing your images correctly.

(Note – we are not attorneys, and so the advice given below should NOT be taken as legal advice, nor are we responsible for any damages you may incur as a result of using one of the services we recommend below)

Do not Use Google Images

First, stay as far away from Google Images as humanly possible. I cannot overstate the importance this enough. Sure, when you do an image search on Google you might find what you are looking for, and it might seem like a perfect match for the blog post you are writing. However, even though it says “Images may be subject to copyright”, you need to assume that you cannot use any of them.

The issue is that someone might post an image that they think is open-source, but it is possible that the license expired, or they purchased a one-time license for the image that only applies to the buyer. So if they re-post this image and you use it, you technically do not own the rights to the image.

Sure, some of these images might be safe to use, but most of them are not. Better to be safe than sorry in our experience.

What Happens if I Get Sued?

It will vary, but these days what can happen is that attorneys will search website images to see if the site owner legally owns an image, or images on their website. If not, they may wait for a period of time and then claim that their representative (possibly the owner of the image) is suing for a specified amount, usually over $8k, over copyright infringement. This has happened to many website owners.

Once this happens they may try to settle with you for the above amount. If you do not settle, they may or may not try to take you to court for more significant damages. Either way, having to drop $10k or more is often a hit that a small business cannot survive.

The best way to avoid it is to be careful where you source your images.

Ok – I Am Sufficiently Worried. Where Can I Get Safe Images?

Pixabay offers free, open-source images. Some images claim to have model-releases for images to be used for websites or blogs safely. Others require that the images are only used for a specific purpose, such as for editorial use. Be very careful with those images in how you use them. Generally you can go to Pixabay, do a search and find the image you are looking for to use on your site.

However, please make sure to read their disclaimer on each image, the image details, and if any credit needs to be given to the photographer or image owner.

Alternatives include Unsplash and FreeImages.

If you would rather use a premium service for paid images, then 123rf, Dreamstime and Shutterstock are good alternatives. These all contain high-quality images and you are essentially buying the rights to use them, sometimes for a limited period of time. However, as with the warning above about Pixabay, make sure that you read the details of use for each image.

Can I Get Help With Images?

We are happy to take a look at your situation and assist you with sourcing your images. Again, while we are not attorneys, we can at least help point you in the right direction. Feel free to contact us if you should have any questions.