WordPress-Login via IP-address

URL dieses Beitrags: http://blog.stefan-macke.com/2006/11/28/wordpress-login-via-ip-address/

Last week I took a closer look at WordPress to find out, whether I could use it as a multi-user blogging platform in my company. I had already tried LifeType, Drupal and WordPress Mu, but they all had their disadvantages (which I don’t want to explain at this point, but you may look here (German) if you are interested).

The only thing I needed, to make it as easy as possible for our employees to use the platform, was an automatic login via their IP-adresses. I use this way of authentication on some other sites on our intranet, too. I know, it is not a very secure way of authenticating your users, but as long as it is only a “free” blogging platform for all employees of the company, all I needed was the users to be logged in automatically, when they visit the site.

After searching the internet for some time, I found no plugin that fit my needs, so I decided to create one myself. However, WordPress’ API is very well documented and so after a short time, my plugin was finished.

Description

The plugin makes use of WordPress’ wp_usermeta-table, where you can store all kinds of information about your users. All you need to do is create a field named ipaddress, that contains the corresponding user’s IP-address.

I did this via PHP in our Windows-logon script, but you are free to come up with any other way of inserting the IP-address into the table :) The only problem is, that you have to find out the user’s ID in wordpress. In my case this is easy because WordPress and Windows usernames are the same, so I can search the wp_users-table for the current Windows username and return the ID.

I think by using the plugin Userextra you could even be able to enter the IP address manually into the user’s profile…

An example SQL-statement (2 is the ID of the user that will be logged in, if IP 172.16.123.124 visits the site):

  1. INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (50, 2, ‘ipaddress’, ’172.16.123.124′);

Of course you should not insert new rows into the table everytime an IP-address changes (use UPDATE instead).

Download / Source code

Kommentare zu diesem Beitrag

  1. Gravatar Stefan Macke » Blog Archiv » Wordpress als Blog-Plattform im Unternehmen
    Am 21. April 2007 um 23:57 Uhr

    [...] Um den Benutzer nun automatisch anzumelden, sobald er die Seite besucht, ist das entsprechende Plugin erforderlich. Dieses gibt es inkl. (englischer) Beschreibung hier: WordPress-Login via IP-address. [...]

  2. Gravatar Wordpress-Login via IP-address » Stefan Macke
    Am 2. Oktober 2011 um 19:56 Uhr

    [...] = 'wpp-256'; var addthis_config = {"data_track_clickback":true}; View post :     WordPress-Login via IP-address » Stefan Macke Random Bookmarks:Audacity: Free Audio Editor and RecorderMacgamefiles.com: Free Mac Games [...]

Einen Kommentar schreiben

XHTML: Diese Tags sind erlaubt: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>