15 Dec

How to build a custom register page in Wordpress

So, I'm running Wordpress on this blog, but I don't like the way users are directed to pages in this blog wich don't have the lay-out I chose. But to change this, there are no real good tutorials on the web, so I had to invent a way of doing this. First is the register page.
update: Right after publishing this, I stumbled upon this plugin, ah well, that's life I guess.
update 2: Scroll down for downloadable files. These work for the default kubrick theme, if your using a different theme these are stil worthwhile downloading, because there are a lot of minor changes to do, wich are already done in this file. See note 3 for more details.

The register page is found in your wordpress install dir, and is named wp-register.php. Copy this file, and name this copy register.php (or any other name you fancy). Open the copy in a text editor, and find the following lines;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>WordPress » 
	<meta http-equiv="Content-Type" content="; charset=<?php echo get_settings('blog_charset'); ?>" />
	<link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
	<style type="text/css">
	.submit {
		font-size: 1.7em;
	}
	</style>
</head>
<body>

These lines are found three times in the wp-register.php file of my install (currently Wordpress 2.0.5).

Now for my blog I use an altered version of the default kubrick theme. So I'll replace the code with this:

<?php require_once(TEMPLATEPATH . '/header.php'); ?>

	<div id="content" class="narrowcolumn">

In the same way, the lines

</div>
</body>
</html>

Are replaced with

</div>
<?php require_once(TEMPLATEPATH . '/sidebar.php'); ?>

<?php require_once(TEMPLATEPATH . '/footer.php'); ?>

This is also done three times. Save the file to your wordpress install dir. Now, if I go to this page, I have a custom register page. You can adjust the wp-login.php in a similar way.

Note: This is the way to go for the default Kubrick theme, for other themes there will be other lines of code to enter. Just look at your standard page template, and work from there. Just remember that Wordpress functions like get_header() won't work, and have to be replaced by the require_once(TEMPLATEPATH. kind of things used above.

Note 2: The wp-login.php file redirects to the user profile in the admin pages. If you don't want users to be redirected there, look in the file for things like $redirect_to = 'wp-admin/';, and replace it with $redirect_to = '/'; or wherever else you want your readers to be redirected.

Note 3: The newly created register.php contains some links to the wp-register.php and wp-login.php files. For full effect of these changes, these links need to direct to the register.php or login.php files. The same goes for the login.php file.

Note 4: Now that you've struggled through this tekst, it would be kind of lame for me to say that I've included the files created in this little tutorial in a convenient zip-file, wich you could easily extract to your Wordpress install dir, and it should work with Wordpress 2.0 if you use the kubrick theme.

 

One Response to “How to build a custom register page in Wordpress”

Trackbacks

Leave a Reply