How to disable bbpress registration?

January 14th, 2011 at 12:55pm Jason 299 views

Q: how can I disable registration in bbpress? I have added the Admin add user plug-in. and want to restrict registration so it is done manually.

A: Rather than editing or removing core files, This is a simple plugin can disable bbpress registration. U can use your plugin or link your user to register on ur wordpress website if you have Integrated your wordpress and bbpress.

<?php
/*
Plugin Name: Disable Registrations
Description: This plugin disables access to registration.php and blocks any registrations.
Version: 0.1
*/
 
// Fires every time bbPress inits, a bit ick but it's super quick string ops
// (which is what PHP is good at).
function da_disable_registrations()
{
	// Shame there isn't a hook to grab before the new user is registered on register.php
	// In the absence of that, we will check whether we're on register.php
	if ( ! da_str_ends_with( strtolower( $_SERVER[ 'PHP_SELF' ] ), 'register.php' ) ) return;
	// We are on register.php? Stop executing (with a message).
	bb_die( "Registration is not allowed on this website. Please contact the site administrators." );
	exit; // Never reached, unless bb_die fails for some freaky reason
}
 
// Checks whether string a ends with string b
function da_str_ends_with(& $str, $end)
{
	return ( substr( $str, - strlen( $end ), strlen( $end ) ) == $end );
}
 
add_action( 'bb_init', 'da_disable_registrations' );
 
?>

Entry Filed under: WordPress Tagged with:

Share This Post Share This Post SubscribePrint This Post Print This PostSave As PDF Save As PDF

Related Posts Hot Posts Hot Comments Hot Tags

      1 Comment Add your own

      • 1. xiaodi zhan  |  August 2nd, 2011 at 9:49 am

        good

      Leave a Comment

      Required

      Required, hidden

      Some HTML allowed:
      <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

      Trackback this post  |  Subscribe to the comments via RSS Feed


      Calendar

      January 2011
      MTWTFSS
      « Nov Feb »
       12
      3456789
      10111213141516
      17181920212223
      24252627282930
      31 

      Sponsors

      Most Recent Posts