Force User Registrations to your own BuddyPress Registration page

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:

{code type=php}

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)


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).

Related plugins and articles

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