Replies
- Ravi on April 24, 2016 at 4:15 am in reply to: [Resolved] Excluding current logged in user from members widget? #3695
Hi Alayna,
Thank You for confirming.
Thank You
Ravi Hello Brendan,
It should be in “wp-content/plugins/” directory. If it is not present create one. You can refer following url
https://buddydev.com/docs/guides/guides/buddypress-guides/what-is-bp-custom-php/
Thank You
Ravi- Ravi on April 23, 2016 at 7:40 am in reply to: [Resolved] Excluding current logged in user from members widget? #3689
Hi Alayna,
Thank you for posting. Please use the following code in your bp-custom.php and let me know if it works or not
function buddydev_exclude_users( $args ) { //do not exclude in admin if( is_admin() && ! defined( 'DOING_AJAX' ) ) { return $args; } $excluded = isset( $args['exclude'] )? $args['exclude'] : array(); if( !is_array( $excluded ) ) { $excluded = explode(',', $excluded ); } $user_ids = array( bp_loggedin_user_id() ); //user ids $excluded = array_merge( $excluded, $user_ids ); $args['exclude'] = $excluded; return $args; } add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' );
Thank You
Ravi Hi Brendan,
Brajesh Sir is away so I am posting here. Please use the following code in your bp-custom.php file
and let me know if it works or not.function buddydev_filter_buddyblog_settings( $settings ) { if ( ! is_user_logged_in() ) { return $settings; } // Get the current user in the admin $user = new WP_User( get_current_user_id() ); // Get the user role $user_cap = $user->roles; // Get the user login name/ID if ( function_exists( 'get_users' ) ) $user_login = $user->user_nicename; elseif ( function_exists( 'get_users_of_blog' ) ) $user_login = $user->ID; $defaults = array( 'RestrictCategoriesDefault' ); // Get selected categories for Roles $settings = get_option( 'RestrictCats_options' ); // Get selected categories for Users $settings_user = get_option( 'RestrictCats_user_options' ); $user_key = $user_login . '_user_cats'; $term_ids = []; if ( is_array( $settings_user ) && array_key_exists( $user_key, $settings_user ) && count( $settings_user[ $user_key ] ) > 1 ) { $settings_user[ $user_key ] = array_values( array_diff( $settings_user[ $user_key ], $defaults ) ); $user_terms = $settings_user[ $user_key ]; foreach ( $user_terms as $term ) { $term_ids[] = get_term_by( 'slug', $term, 'category')->term_id; } } else{ foreach ( $user_cap as $key ) { if ( is_array( $settings ) && !empty( $settings[ $key . '_cats' ] ) ) { $settings[ $key . '_cats' ] = array_values( array_diff( $settings[ $key . '_cats' ], $defaults ) ); foreach ( $settings[ $key . '_cats' ] as $category ) { $term_ids[] = get_term_by( 'slug', $category, 'category' )->term_id; } } } } $settings['tax'] = array( 'category' => array( 'include' => array_unique( $term_ids ), 'view_type' => 'checkbox' ) ); return $settings; } add_filter( 'buddyblog_post_form_settings', 'buddydev_filter_buddyblog_settings' );
Thank You
RaviHi Leo,
Please upgrade BP Simple Front Post plugin. After that create post from that form it will work. There was an issue in custom fields which We have fixed in newer version.
Thank You
Ravi- This reply has been marked as private.
Hi Leo,
Yeah, I am asking website url and user access so that i can test the issue
Thank You
RaviHi Leo,
You can try this code as this action provide user_id as parameter
function xprofile_bio_field_activity( $user_id ) { $bp = buddypress(); if ( ! function_exists( 'bp_activity_add' ) ) { return false; } $userlink = bp_core_get_userlink( $user_id ); bp_activity_add( array( 'user_id' => $user_id, 'action' => apply_filters( 'xprofile_bio_field_action', sprintf( __( '%s has just registered for this website', 'buddypress' ), $userlink ), $user_id ), 'content' => bp_member_profile_data('field=Bio'), 'component' => 'profile', 'type' => 'new_user_bio' ) ); } add_action( 'bp_core_activated_user', 'xprofile_bio_field_activity' );
Hi Leo,
I have testing this code on my local machine as it is working fine. When editing blog post it loads normal blog form and in case editing blog post published from our custom form loads custom form for editing. No category is changing while blog post are being updated.
Can you please share your application url so that I can check what actually is going over there.
Thank You
Ravi- Ravi on April 15, 2016 at 5:06 am in reply to: Group Categories and restricting which ones display. #3521
Hi Phil,
If you disable the taxonomy. Post will be post to uncategorized category. But by doing custom code we can create post in any particular category.
Thank You
Ravi