[buddypress-trac] [BuddyPress Trac] #7872: Errors with add_filter('bp_groups_default_extension', ... in BP 3.0

buddypress-trac noreply at wordpress.org
Fri May 25 17:22:19 UTC 2018


#7872: Errors with add_filter('bp_groups_default_extension',... in BP 3.0
-------------------------------+------------------------------
 Reporter:  gcmaryland         |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Groups             |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |
-------------------------------+------------------------------

Comment (by gcmaryland):

 Thanks @r-a-y for checking into this - I've found the bug to be somewhat
 randomly applied, and have even been able to get these plug-ins to work
 for 1-page load by activating them, removing the filter line, and
 reloading the specific custom page - however, this only works once, and
 then has to be repeated.

 I've provided some scratch code that follows the model of most of the
 plug-ins with incompatibilities that we've found:


 {{{
 <?php
 /*
 Plugin Name: Sample Compatibility Checker
 Description: Verify meta data plug-in compatability with BP 3.0.0
 Version: 0.1
 Requires at least: 3.3
 Tested up to: 4.8.1
 Author: null
 Author URI: https://null
 */

 //////////////////// BuddyPress Group Meta Management:
 https://codex.buddypress.org/plugindev/how-to-edit-group-meta-tutorial/
 function bp_group_meta_init_checker() {
 function custom_field($meta_key='') {

 //get current group id and load meta_key value if passed. If not pass it
 blank
 return groups_get_groupmeta( bp_get_group_id(), $meta_key) ;
 }

 // This function is our custom field's form that is called in create a
 group and when editing group details
 function demo_checker_fields_markup() {
 global $bp, $wpdb;
 //////////////////// End BuddyPress Group Meta Management

 //////////////////// Front-End Output
 ?>

 // Output front-end editor settings.

 <?php
 //////////////////// End Front-End Output

 //////////////////// Insert Group Meta
 // This saves the custom group meta – props to Boone for the function
 // Where $plain_fields = array.. you may add additional fields, eg
 //  $plain_fields = array(
 //      'field-one',
 //      'field-two'
 //  );
 }
 function demo_checker_fields_save( $group_id ) {
         global $bp, $wpdb;
         $plain_fields = array(
                 // Fields
         );

         foreach( $plain_fields as $field ) {
                 $key = $field;
                 if ( isset( $_POST[$key] ) ) {
                         $value = strip_tags($_POST[$key]);
                         groups_update_groupmeta( $group_id, $field, $value
 );
                 }

         }
 }

 add_filter( 'groups_custom_group_fields_editable',
 'demo_checker_fields_markup' );
 add_action( 'groups_group_details_edited', 'demo_checker_fields_save' );
 add_action( 'groups_created_group',  'demo_checker_fields_save' );
 //////////////////// Insert Group Meta

 //////////////////// Begin Header Output
 // Show the custom field in the group header

 }

 add_action( 'bp_include', 'bp_group_meta_init_checker' );

 function demo_checker_page() {
         if ( class_exists( 'BP_Group_Extension' ) ) :
                 class Checker_Page extends BP_Group_Extension {
                         function __construct() {
                                 $args = array(
                                         'slug' => 'checker',
                                         'name' => 'Checker',
                                         'create_step_position' => 21
                                 );
                                 parent::init( $args );
                         }
                         function settings_screen( $group_id ) {
                                 // Settings Screen
                         }
                         function display() {
                                 /* Use this function to display the actual
 content of your group extension when the nav item is selected */
                                 global $bp;
                                 echo "It works!";
                         }
                 } // end of class

                 bp_register_group_extension( 'Checker_Page' );

                 endif;
 }

 add_filter('bp_groups_default_extension', 'demo_checker_page' );

 ?>
 }}}

 Again, these 404 errors only occur in 3.0.0, and not in 2.9.4. Thanks for
 checking into this!

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7872#comment:2>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list