Reply To: [Resolved] Group Extension API – Display() under Admin
I was unable to get a correctly working form when i use the plugin page on the ADMIN tab. It shows only. So i revert back to get the job manager on a separate page who shows up on a group page.
The snippet is set for admins only and to work only on group ID 13 and 9.
Anything is commented so you can modify that
Here a slightly modified version of my previous.
Install the plugin and use the shortcodes as indicated by the author and add the snippet to theme’s functions.php or bp-custom.php
function bpfr_add_page_to_group() {
global $bp;
if ( bp_is_active( 'groups' ) )
// allow oly admin's
// this works also on single install
if ( is_super_admin() ) :
if ( class_exists( 'BP_Group_Extension' ) ) :
class Job_Center_Group_Extension extends BP_Group_Extension {
//building the tab
function __construct() {
$args = array(
'slug' => 'jobcenter', // tab slug - mandatory
'name' => 'Job Center', // tab name - mandatory
//'parent_slug' => 'admin',
);
parent::init( $args );
} // end construct()
// content display
function display() {
// grab page or post ID
$id = 240;
$p = get_post($id);
// output the post
echo apply_filters('the_content', $p->post_content);
} // end display()
} // end class
//display content only in one group (ex. group_ID is 14)
// check for a group ID
if( bp_has_groups() ) {
// Grab current group ID
bp_the_group();
$group_id = bp_get_group_ID();
}
// apply our changes only to this group
// conditionnal action
if ( $group_id == 9 OR $group_id == 13 ) {
bp_register_group_extension( 'Job_Center_Group_Extension' );
}
endif;
endif;
}
add_filter('bp_groups_default_extension', 'bpfr_add_page_to_group' );
If you want to modify one of the plugin templates, make a copy of wp-job-manager/templates/ folder in your child theme and rename it job_manager ( ! no other name).