Forum Replies Created
-
I’ve tried with putting the function on the global scope, and yes,
class_exists( 'BP_Group_Extension' )
now returnstrue
, but there is no added menu item in the groups, and no slug calledtasks
I only get fatal error
class declarations may not be nested
. I that I may have this be a function living in the global scope, but thats extremly ugly OOP-wise.Also: according to Group Extension API/ it should not be neccessary, as this method is to declare the class during plugin initiation.
I’m doing a call to
bp_register_group_extension( 'EP_Group_Tasks' );
with a class I want to extend theBP_Group_Extension
class. Full code of the file:<?php /** * User: jimtrim * Date: 11/11/14 * Time: 09:17 */ if ( class_exists( 'BP_Group_Extension' ) ) { class BP_Group_Tasks extends BP_Group_Extension{ /** * Here you can see more customization of the config options */ function __construct() { $args = array( 'slug' => 'tasks', 'name' => __('Tasks', 'revyweb'), 'nav_item_position' => 90, 'screens' => array( 'create' => array( 'name' => __('Create task', 'revyweb'), 'submit_text' => __('Save task', 'revyweb') ), 'edit' => array( 'name' => __('Edit task', 'revyweb'), 'submit_text' => __('Save task', 'revyweb') ), 'admin' => array( 'name' => __('Administer task', 'revyweb'), 'submit_text' => __('Save task', 'revyweb') ), ), ); parent::init( $args ); } function display() { //get_template_part( 'buddypress/custom/view', 'tasks' ); $group_id = bp_get_group_id(); echo "GET READY FOR SOME TASKS"; } public function settings_screen( $group_id = null ) { //get_template_part( 'buddypress/custom/settings', 'tasks' ); $setting = groups_get_groupmeta( $group_id, 'task_name' ); ?> Save your task name here: <input type="text" name="task_name" value="<?php echo esc_attr( $setting ) ?>" /> <?php } function settings_screen_save( $group_id = NULL ) { $setting = ''; if ( isset( $_POST['task_name'] ) ) { $setting = $_POST['task_name']; } groups_update_groupmeta( $group_id, 'task_name', $setting ); } } bp_register_group_extension( 'EP_Group_Tasks' ); } else { $msg = "Class BP_Group_Extension not found for Revyweb_Personal"; // trigger_error($msg, E_USER_NOTICE); echo $msg; }
Edit: yes, User Groups are enabled, and I can display user groups on the frontend, but I can’t add my own BP_Group_Extention
That’s the same as I am trying. My problem is that
class_exists( 'BP_Group_Extension' )
returns false, which means that what I put in myif
never get executed. But I’m happy to hear it’s working for you, what version of BP are you running? And are you running this in a plugin or in a theme?