[wp-hackers] Wordpress as a CMS with user authentication

Trevor Turk trevorturk at yahoo.com
Wed Sep 14 23:28:59 GMT 2005


--- Matt Mullenweg <m at mullenweg.com> wrote:

> Could you try out this patch and let me know if it
> helps things?
> 
> http://trac.wordpress.org/changeset/2876
> 
> It should allow the redirects to be more flexible.

Thanks so much for the quick response! I think it's
very important to avoid hacking up core files - makes
upgrading much easier.

I put together a plugin that takes advantage of this
new code. I'm no PHP expert, and I would appreciate
any help in making it better. Basically, it uses the
"init" hook and checks if you're logged in already and
if the "redirect_to" variable has already been set -
if all is clear, it will set "redirect_to" to your
blog's home page.

I think I can use the "wp_header" hook to add CSS that
would allow me to change the image, and other visual
aspects of the wp-login page. I'll try and do that via
a plugin as well.

Here's the plugin, and thanks for the help!

<?php
/*
Plugin Name: Redirect to Blog
Plugin URI: http://wordpress.org
Description:  Redirects to your Blog's home page
instead of the admin interface on initial login, which
is good if you're forcing users to log in before they
can see your site.
Version: 1.0
Author: Mr. Wordpress
Author URI: http://wordpress.org
*/

function redirect_to_blog() {
	
	global $userdata;
	get_currentuserinfo();
	
    if( ( !isset($_REQUEST['redirect_to']) ) && (
!isset($userdata->user_login) ) ) {
		$_REQUEST['redirect_to'] = get_bloginfo('url');
		}
    }

add_action('init', 'redirect_to_blog');
?>


More information about the wp-hackers mailing list