Force User Registrations to your own BuddyPress Registration page

Do you have a problem with spambot registrations or have custom fields added to your BuddyPress Registration page? Maybe users are getting to the /wp-login.php?action=register page instead of your /register/ page? Here’s a snippet I came up with to redirect the first to the second.

The Code

Put this snippet in your active theme’s functions.php file or in your own plugin:

function force_my_own_registration_page() {
// by Clifford Paulick, 2012-08-09, tested with WP 3.4.1 and BP 1.6

$turnon = 1; // 1 = yes, 0 = no

$currenturl = strtolower($_SERVER["HTTP_HOST"]) . strtolower($_SERVER["REQUEST_URI"]);
$findme = 'wp-login.php?action=register';
$pos = strpos($currenturl, $findme);

if ( $turnon == 1 && $pos !== false) {
wp_safe_redirect( '/?p=8' , 301 );

add_action('init', 'force_my_own_registration_page');

Code references and variations

  • In the code above, my /register/ page is page ID 8. This way, if I change /register/ to /signup/, the code still works. Edit the snippet for your purposes.
  • To add additional URLs to find and redirect, you can add more variables and if statements, just copying the logic. If you create separate functions instead, make sure to name them differently (i.e. not duplicate the function name).
  • I added a $turnon variable so you can deactivate the functionality without having to comment out the code. It’s not really better or worse, just an option that’s there for you.
  • The wp_safe_redirect function
  • The wp_redirect function (for redirecting outside the referring domain; make sure to add the exit command)

Featured Plugin - WordPress Membership Site Plugin

If you're thinking about starting a paid, or just private, membership site then this is truly the plugin you've been looking for. Easy to use, massively configurable and ready to go out of the box!
Find out more


WordPress’ wp-login screen has a link to the /wp-login.php?action=register page.

Clicking to the /wp-login.php?action=register page (without my snippet) will result in the following registration page.

We want users to go to our BuddyPress registration page, as chosen in the BuddyPress settings.

With my snippet above, if they get to the /wp-login.php?action=register URL, they’ll be redirected to our specified BuddyPress Registration page (where all the plugins and BuddyPress profile fields are).

Featured Plugin - WordPress Pop-Up Chat Plugin

No javascript required, no third part chat engine, just fully featured chat right in your own database on your own WP sites - couldn't be easier.
Find out more

Related plugins and articles

You may want to use this code snippet together with these plugins and articles:

Tags ,

Comments (5)

  1. Hi! Thanks for a tutorial! However it didn’t work in my case. As I understood the only thing I have to change in the snippet – is the post/page id, right? I changed it, but it just gave the error massage at the top of my web-site. Any ideas of why it is not working?