Auto Login to wordpress

Sometimes, in wordpress, what we need is to make a user auto log in. Solution for this is very simple. Just put the following code in your functions.php :-

function auto_log_me_in($user_login) {
$user = get_userdatabylogin($user_login);
$user_id = $user->ID;
wp_set_current_user($user_id, $user_login);
wp_set_auth_cookie($user_id);
do_action(‘wp_login’, $user_login);
}

Now call
auto_log_me_in($user_login);
where you want to make a user auto log in. Here “$user_login” is the user name to whom one want to make log in.

A custom twitter widget without any plugin

Last time, when i was working on a HTML and CSS based project, was not using any content management system such as WordPress or Joomla, I wanted to display my last tweet from twitter, and jazz it up using css. Now when people usually want to display their last tweet, and are running wordpress, they usually just install a plugin to do it for them.

As my site was only HTML and CSS. So I looked into the Twitter API, and found a way you can display your last tweet using the twitterCallback javascript function. I have summed it up in a few easy to follow steps:

First, place the following code where you want the list to show up:

<ul id="twitter_update_list"><li>

Twitter feed loading</li></ul>
Note: The <li>Twitter feed loading</li> is not a part of the original code Twitter provided, but it’s required to make the HTML validate. It can also provide a useful message while the feed is loading, as it could take a few seconds on a slow day.

Second, you’ll need to place the following lines of Javascript as close to the </body> tag as possible.
<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/twitter.json?callback=twitterCallback2&count=3"></script>

Note: – Replace “twitter.json” with your own USERNAME.json.

Third, give some styles to make your twitter widget some stylish.

<style type="text/css">
    #twitter_update_list {
        background: #414346;
        font-size: 13px;
        line-height: 21px;
        list-style: none;
        width: 300px;
        padding-left: 10px;
    }
    #twitter_update_list li {
        padding-bottom: 7px;
        margin-bottom: 9px;
        border-bottom: 1px #fff solid;
    }
    #twitter_update_list span, #twitter_update_list span a {
        color: #ababab;
        text-decoration: none;
    }
    
    #twitter_update_list a {
        color: #6f7276;
    }
</style>

And that’s it!