Our Vision

Your Business Revitalized

We are a Denver, Colorado based consulting firm specializing in helping you define your business goals and driving sales through professional media. We offer high quality branding, web design and development, mobile app and game development, self-publishing assistance for authors, email marketing and strategic business consultation.

Get Started!
Mike Lazear
Mike Lazear, Founder & CEO

A Message from the Founder

Welcome to the 515 Media company website! We look forward to helping you create your new business vision. I’ve had the joy of helping so many clients embark on a new professional journey and their businesses become a huge success. We would love to be a part of your success as well. So glad to have you with us!

Mike's Signature

Branding

Work with our team to define your brand, message and image. Not sure where to begin? Looking to stand out from competitors and leave a lasting impression with your clients? We can help!

Stellar Media

If you are looking for quality web design, development, print, custom video and front-end user-interface and application design, you have come to the right place.

Your Vision

515 Media specializes in helping you define your business goals. Schedule a free consultation today and we will meet with you to help you crystalize your new process!

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!

Read More Posts