This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Sort loop by last name field. | |
| function alphabetize_by_last_name( $bp_user_query ) { | |
| if ( 'alphabetical' == $bp_user_query->query_vars['type'] ) { | |
| $bp_user_query->uid_clauses['orderby'] = "ORDER BY substring_index( u.value, ' ', -1 )"; | |
| } | |
| } | |
| add_action ( 'bp_pre_user_query', 'alphabetize_by_last_name' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // check user against an existing buddypress group | |
| // I needed this in a category.php file to see if | |
| // we were looking at a specific category, and if | |
| // so, check if the user is in a buddypress group | |
| // to ensure they should have access | |
| if ( has_category( 'Some Category') && function_exists( 'groups_is_user_member' ) ) { | |
| $group_id = BP_Groups_Group::group_exists('buddypress-group-slug'); | |
| $is_member = groups_is_user_member( wp_get_current_user()->id, $group_id ); | |
| if ( !$is_member ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Add this function to theme's functions.php | |
| * | |
| * Add links to BuddyPress navigation. | |
| * This will add photo, video and music link to BuddyPress navigation. | |
| * | |
| * If you don't want to display "Media" tab, then add following css to | |
| * rtMedia->Settings->Custom CSS: | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action('template_redirect', 'bp_private_profile'); | |
| function bp_private_profile() { | |
| if ( ! current_user_can( 'manage_options' ) ) { | |
| if ( bp_is_user_profile() && ! bp_is_my_profile() ) { | |
| wp_redirect( home_url() ); | |
| exit; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Create an activity item to appear in a group. Fires once a post has been saved. | |
| * | |
| * @param int $post_ID Post ID. | |
| * @param WP_Post $post Post object. | |
| * @param bool $update Whether this is an existing post being updated or not. | |
| */ | |
| function add_activity_item_for_group( $post_id, $post_object, $update ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function custom_filter_notifications_publish_post_get_registered_components( $component_names = array() ) { | |
| // Force $component_names to be an array | |
| if ( ! is_array( $component_names ) ) { | |
| $component_names = array(); | |
| } | |
| // Add 'custom' component to registered components array | |
| array_push( $component_names, 'custom' ); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function job_listing_activity_args() { | |
| if ( ! bp_is_active( 'activity' ) ) { | |
| return; | |
| } | |
| add_post_type_support( 'job_listing', 'buddypress-activity' ); | |
| bp_activity_set_post_type_tracking_args( 'job_listing', array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* groups_join_group is called whenever someone joins a group. */ | |
| add_action('groups_join_group', 'group_join_add_ancestors', 10, 2); | |
| function group_join_add_ancestors( $group_id, $user_id ) { | |
| // I'm assuming that you'll want to join to all ancestors: | |
| $ancestor_ids = hgbp_get_ancestor_group_ids( $group_id ); | |
| // To only include groups that the user can visit, use this version: | |
| // $ancestor_ids = hgbp_get_ancestor_group_ids( $group_id, $user_id ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php if ( bp_docs_is_doc_edit() || bp_docs_is_doc_create() ) : ?> | |
| <?php bp_docs_media_buttons( 'doc_content' ) ?> | |
| <?php endif; ?> | |
| <?php | |
| // Maybe you'll want to do something with main doc ID. | |
| $doc_id = get_the_ID(); | |
| ?> | |
| <ul id="doc-attachments-ul"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'bp_user_can', 'my_create_groups_cap_change', 20, 5 ); | |
| function my_create_groups_cap_change( $retval, $user_id, $capability, $site_id, $args ) { | |
| if ( 'create_subgroups' == $capability ) { | |
| // We need to know which group is in question. | |
| if ( empty( $args['group_id'] ) ) { | |
| return false; | |
| } |