Skip to content

Instantly share code, notes, and snippets.

@imath
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imath/9663354 to your computer and use it in GitHub Desktop.
Save imath/9663354 to your computer and use it in GitHub Desktop.
Faire en sorte que les pages BuddyPress ne soient accessibles qu'aux membres connectés.
<?php
/**
Seulement visible pour les utilisateurs connectés
Portion de code à mettre dans bp-custom.php
Voir le codex: http://codex.buddypress.org/plugindev/bp-custom-php/
**/
function check_is_user_logged_in() {
if ( ! is_buddypress() )
return;
// Il faut permettre l'inscription !!
if ( bp_is_register_page() || bp_is_activation_page() )
return;
if ( ! is_user_logged_in() ) {
/**
* Redirection vers la page d'accueil du blog sur lequel est actif BuddyPress
* Tu peux changer par l'url de ton choix
*/
$url = trailingslashit( get_home_url( bp_get_root_blog_id() ) );
bp_core_redirect( $url );
}
}
add_action( 'bp_actions', 'check_is_user_logged_in', 1 );
@Favorwilliams
Copy link

My Pleasure to write you,
My name is Favor Williams,
My email address is
( Favor24@live.com)
Am interested to know
more about you,
Contact me for my
photo and other
important issue via,

Favor24@live.com

@solhuebner
Copy link

Nice addition!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment