Custom sidebar in Secondary Sidebar location
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
<!-- To register and display a custom sidebar in Secondary Sidebar location for logged in users -->
//* Register Members only Secondary sidebar
genesis_register_sidebar( array(
'id' => 'members-secondary',
'name' => __( 'Secondary Sidebar (Members)', 'metro' ),
'description' => __( 'This is the members only secondary sidebar.', 'metro' ),
) );
//* Show Members only custom Secondary sidebar in Secondary Sidebar location
add_action( 'genesis_after_header', 'sk_change_genesis_secondary_sidebar' );
function sk_change_genesis_secondary_sidebar() {
if( is_user_logged_in() && is_active_sidebar( 'members-secondary' ) ) {
// Remove the Secondary Sidebar from the Secondary Sidebar area.
remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
add_action( 'genesis_sidebar_alt', 'sk_do_sidebar_alt' );
}
}
function sk_do_sidebar_alt() {
dynamic_sidebar( 'members-secondary' );
}