cuny-academic-commons / bp-event-organiser

Allows Event Organiser plugin events to be assigned to BuddyPress groups and generates a group calendar page for each group
GNU General Public License v2.0
3 stars 1 forks source link

Introduce "bpeo_edit_screen_before_display" action #58

Closed christianwach closed 7 years ago

christianwach commented 7 years ago

@r-a-y This is a bit of an oddity - I can't seem to find an appropriate hook that tells me that I'm on a BPEO edit screen. Please ignore this PR if there's a hook that I've overlooked.

FWIW, the reason for introducing this hook (or a hook like it) is that (due to a limitation in CiviCRM) I use Radio Buttons for Taxonomies to force events to have only a single category assigned to them. RBfT transforms the Category metabox by unhooking the built-in one and replacing it with an amended version, but does so via the admin_menu hook - which, of course, does not fire on the front end. The relevant RBfT method can be called directly, but it seems overkill to do so unless it's needed.

r-a-y commented 7 years ago

You should be able to use any of the metabox hooks to do what you want:

        do_action( 'add_meta_boxes', self::$post_type, $post );
        do_action( 'add_meta_boxes_' . self::$post_type, $post );
        do_action( 'do_meta_boxes', self::$post_type, 'normal', $post );
        do_action( 'do_meta_boxes', self::$post_type, 'side', $post );

But, in your hook, you would check to see if you're on the frontend.

eg.

add_action( 'add_meta_boxes_event', function( $post ) {
    // Check to see if we're in the admin area.  If so, bail.
    if ( defined( 'WP_NETWORK_ADMIN' ) ) { return; }

    // We're on the frontend.  Do what you need to do here.

} );

Let me know if that works or not.

christianwach commented 7 years ago

Nice one @r-a-y that works just fine. Thanks!