Shape the future of Social networking with WordPress: Join Project Midnight Sun! The next generation platform for community building with WordPress!

BuddyDev

Search

Replies

  • Keymaster
    (BuddyDev Team)
    Posts: 25473
    Brajesh Singh on in reply to: [Resolved] Auto join groups – cron job #40070

    Hi Darshan,
    You were right. The code from Ravi used an API function that did not return hidden group if the user is context was not logged.

    Here is the updated code. Please make sure to update the profile field id with your own.

    
    
    /**
     * Retrieves all group ids of which the user is a member or has requested membership or is banned.
     *
     * @param int $user_id user id.
     * @param int $limit per page.
     * @param int $page page number.
     *
     * @return array
     */
    function bd_get_user_group_ids( $user_id, $limit = false, $page = false ) {
    	global $wpdb;
    
    	$pag_sql = '';
    
    	if ( $limit && $page ) {
    		$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit ), intval( $limit ) );
    	}
    
    	$bp = buddypress();
    
    	$group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d {$pag_sql}", $user_id );
    
    	return $wpdb->get_col( $group_sql );
    }
    
    /**
     * Sync user's groups
     *
     * @param int   $user_id       User id.
     * @param array $new_group_ids New group ids.
     */
    function buddydev_sync_user_groups( $user_id, $new_group_ids ) {
    
    	if ( ! $user_id || ! $new_group_ids || ! function_exists( 'groups_leave_group' ) ) {
    		return;
    	}
    
    	$existing_user_group_ids = bd_get_user_group_ids($user_id );
    
    	$removable_group_ids = array_diff( $existing_user_group_ids, $new_group_ids );
    	$new_join_group_ids  = array_diff( $new_group_ids, $existing_user_group_ids );
    
    	foreach ( $removable_group_ids as $group_id ) {
    		groups_leave_group( $group_id, $user_id );
    	}
    
    	foreach ( $new_join_group_ids as $group_id ) {
    		groups_join_group( $group_id, $user_id );
    	}
    }
    
    /**
     * Sync user's groups on field save.
     */
    add_action( 'xprofile_data_after_save', function ( BP_XProfile_ProfileData $object ) {
    	$field_id = $object->field_id;
    
    	// Replace field id with yours field id.
    	$group_field_id = 5;
    
    	// If not our field id return.
    	if ( $group_field_id != $field_id ) {
    		return;
    	}
    
    	$new_group_ids = wp_parse_id_list( $object->value );
    
    	if ( empty( $new_group_ids ) ) {
    		// should we remove existing groups?
    		// let us avoid that for now.
    		return;
    	}
    
    	buddydev_sync_user_groups( $object->user_id, $new_group_ids );
    } );
    
    

    This code does not need the the Auto group join plugin. You can still use the plugin for other purpose.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25473
    Brajesh Singh on in reply to: [Resolved] BuddyPress Xprofile – Search URLs #40069

    Thank you.

  • Keymaster
    (BuddyDev Team)
    Posts: 25473

    Hi mdc,
    Thank you for the question.

    No, The plugin is not able to handle multiple conditions currently. The plugin does not load fields/options via ajax, It simply shows/hides them.

    If you are referring to our Ajax Registration plugin, then yes, the current code is compatible.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25473
    Brajesh Singh on in reply to: [Resolved] changing css tags #40067

    Hi David,
    When you change a file url, BuddyPress will not know of its existence. So, you will need to load it on your own to make it available on the front end.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25473

    Hi James,
    Thank you for the question.

    Yes, you can do that with Profile Visibility Manager.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25473
    Brajesh Singh on in reply to: [Resolved] Auto join groups – cron job #40059

    Hi Darshan,
    It seems you are referring to the custom code section. Please allow me to check and get back to you by tomorrow.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25473
    Brajesh Singh on in reply to: [Resolved] BuddyPress Xprofile – Search URLs #40058

    Hi James,
    The search functionality is not offered by Xprofile Custom Field Types plugin.

    It is offered by the BuddyBoss platform and is same for the native fields/custom fields. If you are able to use the link for native fields(such as Web etc), you can apply the same for custom field types.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25473
    Brajesh Singh on in reply to: Branded login and BP Rewrites #40056

    Hi Tosin,
    The change has no effect on Branded login. It is currently allowing you to edit the slug part after the members page. Branded login has no page for tat.

    You can edit branded login slug from your pages screen. Slugs have no special meaning in the case of branded login plugin.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25473

    Hi James,
    Thank you for confirming. I am glad it worked.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25473
    Brajesh Singh on in reply to: [Resolved] BuddyPress Xprofile – Search URLs #40054

    Hi James,
    Thank you for letting me know.

    I will suggest contacting BuddyBoss support as we do not offer any support for BuddyBoss’s product here.
    We do provide support for our plugin’s compatibility with them.

    Regards
    Brajesh