Skip to content

Instantly share code, notes, and snippets.

@tylerdigital
Created June 19, 2013 20:57
Show Gist options
  • Save tylerdigital/5817980 to your computer and use it in GitHub Desktop.
Save tylerdigital/5817980 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: BP Registration Options - Restrict Access Add-On
Plugin URI: http://tylerdigital.com
Description: Add additional restrictions to unapproved members (restrict access to pages/posts)
Version: 1.0
Author: Tyler Digital
Author URI: http://tylerdigital.com
*/
/**
* Copyright (c) 2013 Tyler Digital. All rights reserved.
*
* Released under the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
* This is an add-on for WordPress
* http://wordpress.org/
*
* **********************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* **********************************************************************
*/
add_action( 'template_redirect', 'tdbpro_restrict_access' );
function tdbpro_restrict_access() {
global $bp;
global $post;
if ( !is_user_logged_in() ) return;
if ( empty( $bp->loggedin_user->domain ) ) return;
if ( $post->post_name=='membership-options' ) return;
if(
get_post_type() == 'page' ||
get_post_type() == 'post' ||
get_post_type() == 'forum' ||
get_post_type() == 'topic' ||
get_post_type() == 'reply'
) {
$user = get_userdata( get_current_user_id() );
if ( $user->user_status == 69 ) {
wp_redirect( $bp->loggedin_user->domain );
exit;
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment