Posts tagged ‘Blogs’

Automating parts of a multi-user blog

I manage a "topic blog" for work. For the uninitiated, a "topic blog" has posts from a community of interest on a given topic. Often, topic blogs have lots of contributors. That’s the case for Communicat.us. Managing lots of users requires some tools and some automation.

Today’s tasks included adding 15 new users, sending out the "getting started" guide to everyone, and updating the "authors" page. To make the least work of it all, I added a Dragon Design’s Import Users plug-in for WordPress. That made shore order of adding the 15 new users. But, before I did the upload, I found out how to modify the email that get’s sent for each new user.

WordPress supports "pluggable functions". Fortunately for me, the wp_new_user_notification() function is one of those. Steve Taylor got me started with his basic code for extending the email that gets sent out. Here is what I ended up with …

<?php
/*
Plugin Name: Custom New User Email
Description: Changes the copy in the email sent out to new users
*/

// Redefine user notification function
if ( !function_exists(‘wp_new_user_notification’) ) {
    function wp_new_user_notification( $user_id, $plaintext_pass = ” ) {
        $user = new WP_User($user_id);

        $user_login = stripslashes($user->user_login);
        $user_email = stripslashes($user->user_email);

        $message  = "New user registration for " . get_option(‘blogname’) . ":\r\n\r\n";
        $message .= "Username: " . $user_login . "\r\n";
        $message .= "E-mail:   " . $user_email . "\r\n";

        @wp_mail(get_option(‘admin_email’), get_option(‘blogname’)." – New User Registration", $message);

        if ( empty($plaintext_pass) )
            return;

        $message .= "\r\n\r\n";
        $message .= "To log in:\r\n";
        $message .= wp_login_url() . "\r\n";
        $message .= "Username: " . $user_login . "\r\n";
        $message .= "Password: " . $plaintext_pass . "\r\n\r\n";

        $message .= "You will find the \"getting started\" guide at: ".get_option(‘upload_url_path’)."/getting_started.pdf"."\r\n";

        wp_mail($user_email, "You have been added to " .  get_option(‘blogname’), $message);

    }
}

?>

… Feel free to copy this into a file called "new_user_email.php", upload it to your plugins directory and activate it. Don’t forget to also upload your getting_started.pdf to your upload directory and double check you have set the upload path under Administration >> Settings >> Miscellaneous

Everything was working well but then I noticed the automated "Authors" page was full of the new users with no photos, "nice names" or biographies. The page is generated using an "authors.php" file added to the theme. The problem is that is shows all registered authors. What would be better is if it only showed authors who had actually contributed to the blog. So, I set about to some good ol’ trial and error with "SELECT", "COUNT", "WHERE", "GROUP BY", and "ORDER BY" … aka SQL code. Here is a snippet of the final results …

<table border=0>
<?php
    // Get the authors from the database ordered by user nicename, but only include those with posts
    global $wpdb;
    $query = "SELECT wusers.ID as ID, wusers.user_nicename as user_nicename, COUNT(wposts.post_author) as thecount ";
    $query .= "FROM $wpdb->users wusers, $wpdb->posts wposts ";
    $query .= "WHERE wposts.post_status = ‘publish’ AND wposts.post_type = ‘post’ AND wposts.post_author = wusers.ID ";
    $query .= "GROUP BY wusers.ID ORDER BY wusers.user_nicename";
    $author_ids = $wpdb->get_results($query);

    // Loop through each author
    foreach($author_ids as $author) :
        // Get user data
        $curauth = get_userdata($author->ID);
        // If user level is above 0 or login name is not called "admin", display profile
        if($curauth->user_level > 0 || $curauth->user_login != ‘admin’) :
?>
        <tr><td>
            // show the user profile
            <?php echo (profilepic_internal_profile($author->ID)); ?>
            // show how many posts they have and give a link to posts
            <a href="/index.php?author=<?php echo $author->ID; ?>"><i><?php echo "View " . $curauth->first_name . "’s " . $author->thecount . " post(s)"; ?></i></a>
        </td></tr>
<?php
        endif;
    endforeach;
?>
</table>

So, now I can add new users quickly. New users get the same information to start blogging (both some guides on what is a good blog post as well as the tools they can use to write their posts. Once a users starts to contribute, they will automatically appear on the page of authors.

It was all pretty easy. If you manage a multi-user blog, feel free to use these techniques and take the above code.

Time to move old projects to the archives

In an attempt to “move on” I’m moving some of the permanent pages from the top into posts so they will gradually become just part of the fabric of this blog. The clock project was completed in June of 2007 so I think it’s time to make room for other projects. Here is that page …

This page reserved for information about the Arnold and Lewis, Manchester, England, c. 1880s, Single train tower clock with cast iron flatbed frame design, double three-legged gravity escapement (Denison type) with Harrison style maintaining power, and one and one-quarter second ‘tin whistle’ style compensated pendulum with weight tray.

Check out these posts …

A little house cleaning

Some of you got an error today trying to get to the blog, it’s because I was doing some house cleaning to consolidate the work and personal blog designs. I got sidetracked buy work – hate when that happens – so theSalmonFarm was half down for most of the day.

If you look at the work blog at communicat.us and here, you’ll now see common theming.

(BTW: the errors in this post were caused by unexpected limitations with the mail client on the iPhone – who’d have thought!)

So, what’s the difference between RSS and ATOM ?

There are two answers to the question of “what’s the difference between RSS and ATOM ?” First, there is the technical answer. Second there is the end-user answer. I’ll start with the second.

For the vast majority of end-users today there is very little difference between RSS and ATOM. Both are used as means to get access to information and in nearly all cases that information has been formated into “feeds”. I took a look at my blog statistics and was actually surprised by the ration of RSS to ATOM readers – 250:135. Now, my blog is not a hot bed of traffic so these are small numbers but to be honest, I would have thought RSS was much more prevalent. For technical reasons, which I will get to in a moment, the growing use of ATOM is a good thing.

So, what is the technical advantage of ATOM ? Let’s start by thinking of ATOM and “second generation” RSS. This is not precisely true but many of the reasons for ATOM were direct results of issues that were hard to address with RSS – mostly because RSS was already widely used. In short, it’s hard to change RSS because is is so popular. It may seem strange but that is a big part of why ATOM was initially created. So, “out with the old, in with the new”. We have ATOM.

The big change with ATOM is the focus on interoperability and reuse. For simple feed readers, this is not really important, but ATOM is increasingly being used for computer to computer interactions – data sharing. The more controlled the data format, the easier it is to make two completely separate computers “play well together”. Further, computer programs were no longer just “reading data”. They also wanted to have a method for creating new data, performing updates, and even deleting data. (For the lay person, the technical community call this CRUD for Create, Read, Update, and Delete.) So, the ATOM specification describes the use of HTTP methods GET, POST, PUT, and DELETE. Most system, prior to ATOM, only used GET and POST. For more details, you can get a quick understanding by reading the draft. An advantage of ATOM and it’s use of simple HTTP operations is that most of the internet is already optimized for these types of things. When we consider the billions of internet actions that take place every day, “optimizing” is a big-big challenge so the more that can work with the current internet, the better.

What can you do with ATOM and the HTTP operations ? You could write a blog. More important, you could edit a blog. You could search for a list of artists who have recorded a particular song or search for songs that contain a lyric. Then you could select one title and pay for it and get a link to download it. You could have you computer at home automatically publish updates to your friends or co-workers. You might have a little measuring device in your hot water heater or your air conditioner that provides electric usage to the power company. The power company might send new settings to your hot water heater or air condition to make it conserve electricity. A website could get news from the Associated Press news wire, relevant photos from Flickr, clips from searching blogs, and video from CNN and loads it all into an electronic news paper that refreshes every morning just as your coffee pot finishes brewing. This last one is partially here today using Feed Journal to create a PDF of your blog interests, formatted like a newspaper and the sent to a Kindle digital book and with the structure of ATOM, the reality of the individualized digital newspaper is a programming exercise a high school student could do in less than a day.


Disclaimer: I’m sure, for the technical reader, this post has been a big let down. It may even have been so simplistic that it misrepresented a few things. But technical explicitness was not the the focus. The focus was the “internet minus 1″ generation – those people struggling with what their kids are talking about when they explain the computer and the internet. Everyone needs to get up to speed and even a rickshaw can go 100 miles an hour if you accelerate it enough <grin>

… another blog time waister (but fun all the same)

There are times when blogs have no better role than to break you from your daily routine and make you laugh a little. There needs to be no rhyme or reason. The whole purpose is just to release some stress and realize that, no matter how cynical and up tight the world seems, a little wasted time can make you feel just a few steps further away.

I was reading Return to the Center which referred to the Developing Storm, which referenced Don’s Blog, which found invent Y. At the end of the blog chain was a little exercise to “create your own music CD cover“.

The exercise is easy for anyone with a web browser (and since you read my blog, you have that covered in spades).

  1. Go to Wikipedia’s random article page
    The first article you get is the name of your band
  2. Go to the Random Quotations page
    The last four words of the last quote is the album title
  3. Go to Flickr’s Interesting photo page
    Third picture, no matter what it is, is your album cover

I’m not great at doing layout work and I don’t have my usual tools of hte trade so this is a bit rougher than I’d like but I did find it funny at what I got from the rules above.

BTW, just the fact that you went through five blogs to get to the game says you needed this today !

Social software does not mean “public”

I again was blog surfing this morning and came across a post about sharing items from your blog reader – at least if that blog reader is Google Reader.

Google Reader has some quirky features but one thing is does well is keep your blog reading in check across multiple machines. I tend to have at least three different computers I use regularly and when traveling on short 1 or 2 day trips I try to go without a computer and use what every I can get my hands on if I need to send a quick email or check the news. For these reasons, Google Reader is great.

I collaborate with a number of like minded groups. Mind you, each group is “like minded” but there is not much overlap between the groups. Within each group, we have common topics of interest but very few common sources of information. Sharing blog entries that are informative or of interest has been relegated to either emailing links or cut/paste links into chat windows. Both of these methods escalates blogs to a higher priority which is precisely what we don’t want to do. Blogs and blog reading is a low priority task that should be set aside for prescribed amounts of time and not serve as an interrupt – but I am way off topic at this point so back to Google Reader and sharing information. Let me pull all the important info together now …

  1. Google Reader lets you tag entries and you can tag an entry with more than one tag
  2. Google Reader lets you see a page with all entries of a given tag
  3. Google Reader lets you give any tag-page public address
  4. You get to choose who gets the public address
  5. Recipients of the public address get a “feed” they can add to their blog reader (Google reader not required)

Google has seen the light and written up the instructions here.

I would love to find a similar solution that was “reader independent” because not everyone I collaborate with uses Google Reader.