Last active
August 29, 2015 14:15
-
-
Save gregoirenoyelle/f169cef594c82f3ff5d3 to your computer and use it in GitHub Desktop.
Genesis Private Content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Mettre dans fichier functions.php | |
// bien retirer la balise PHP du début | |
add_action( 'template_redirect', 'gn_filter_content_no_loged'); | |
function gn_filter_content_no_loged( ) { | |
if( is_user_logged_in() || is_home() || is_page( array('3096','3074')) ) | |
return; | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); | |
remove_action('genesis_loop','genesis_do_loop'); | |
add_action('genesis_loop','gn_content_for_connexion'); | |
function gn_content_for_connexion() { | |
genesis_widget_area( 'connexion', array( | |
'before' => '<div class="home-top widget-area">', | |
'after' => '</div>', | |
) ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/////////////////////// | |
// RÉGLAGES CONTENU PRIVÉ | |
// à mettre dans le fichier | |
// functions.php de votre thème | |
/////////////////////// | |
// filtre sur le content | |
add_filter( 'the_content', 'gn_filter_content_no_loged', 20 ); | |
function gn_filter_content_no_loged( $content ) { | |
if( is_user_logged_in() || is_page( '3096') ) { | |
return $content; | |
} else { | |
$mess = '<h3>Contenu réservé</h3>'; | |
$mess .= '<p>Merci de vous rendre sur cette page pour créer votre compte ou connectez vous à droite dans la barre latérale de cette page.</p>'; | |
return $mess; | |
} | |
} | |
// filtres sur le contenu de Genesis | |
add_action( 'template_redirect', 'gn_remove_comment_no_loged' ); | |
function gn_remove_comment_no_loged() { | |
if ( !is_user_logged_in() ) { | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
remove_action( 'genesis_after_entry', 'genesis_get_comments_template' ); | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Mettre dans fichier functions.php | |
// bien retirer la balise PHP du début | |
add_action('template_redirect','gn_display_user_name_sidebar'); | |
function gn_display_user_name_sidebar() { | |
if( !is_user_logged_in() ) | |
return; | |
add_action('genesis_before_sidebar_widget_area','gn_display_name_sidebar'); | |
function gn_display_name_sidebar() { | |
$user_id = get_current_user_id(); | |
$user_data = get_userdata($user_id); | |
echo __('Bonjour ', 'traduction-theme') . $user_data->user_firstname . ' ' . $user_data->user_lastname; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Mettre dans fichier functions.php | |
// bien retirer la balise PHP du début | |
genesis_register_sidebar( array( | |
'id' => 'connexion', | |
'name' => __( 'Connexion Page', 'traduction-theme' ), | |
'description' => __( 'Widget qui gère la connexion. Merci de mettre exclusivement le Widget "Login Form".', 'traduction-theme' ), | |
) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment