Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active February 15, 2017 01:40
Show Gist options
  • Save srikat/769fc125b64ab19585a2c2eb4c5697bc to your computer and use it in GitHub Desktop.
Save srikat/769fc125b64ab19585a2c2eb4c5697bc to your computer and use it in GitHub Desktop.
Make BuddyPress Members page obey its Page layout setting in Genesis. https://sridharkatakam.com/make-buddypress-members-page-obey-page-layout-setting-genesis/
/**
* Make BuddyPress Members page obey its Page layout setting
*/
add_filter( 'genesis_pre_get_option_site_layout', 'sk_do_members_page_layout' );
function sk_do_members_page_layout( $opt ) {
// if the current page is not the members directory, abort.
if ( ! bp_is_members_directory() ) {
return;
}
// get the list of BuddyPress pages from wp_options table
$page_array = get_option( 'bp-pages' );
$opt = get_post_meta( $page_array['members'], '_genesis_layout', true ); // where $page_array['members'] is the ID of BuddyPress Members page
return $opt;
}
add_filter( 'genesis_pre_get_option_site_layout', 'sk_do_buddypress_page_layout' );
/**
* Make BuddyPress Members and Groups pages obey their Page layout setting
*/
function sk_do_buddypress_page_layout( $opt ) {
// if the current page is not the members directory or groups page, abort.
if ( ! ( bp_is_members_directory() || bp_is_groups_component() ) ) {
return;
}
// get the list of BuddyPress pages from wp_options table
$page_array = get_option( 'bp-pages' );
if ( bp_is_members_directory() ) {
$opt = get_post_meta( $page_array['members'], '_genesis_layout', true );
// where $page_array['members'] is the ID of BuddyPress Members page
}
if ( bp_is_groups_component() ) {
$opt = get_post_meta( $page_array['groups'], '_genesis_layout', true );
// where $page_array['groups'] is the ID of BuddyPress Groups page
}
return $opt;
}
@srikat
Copy link
Author

srikat commented Feb 15, 2017

Updated to add code that works for both Members and Groups BuddyPress pages.

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