BuddyDev

Search

Circles for Buddyboss

  • Participant
    Level: Initiated
    Posts: 13
    Bill Perzeski on #50764

    I know we still have issues with buddyboss and displaying circle data properly. Attached is unfinished code that maybe you can use to accomplish this. Please let me know.

    function display_user_circles_and_activities_shortcode() {
        ob_start();
        
        // Check if the user is logged in
        if (is_user_logged_in()) {
            $user_id = get_current_user_id();
    
            // Get the user's circles
            $user_circles = bcircles_get_user_circles($user_id);
            
            if (!empty($user_circles)) {
                // Output a dropdown to select a circle
                echo '<form method="get">';
                echo '<label for="circle-select">Select a Circle:</label>';
                echo '<select id="circle-select" name="circle-id">';
                
                foreach ($user_circles as $circle_id) {
                    $circle = bcircles_get_circle($circle_id);
                    // Display circle names in the dropdown
                    echo '<option value="' . esc_attr($circle_id) . '">' . esc_html($circle->label) . '</option>';
                }
                
                echo '</select>';
                echo '<input type="submit" value="Show Circle Activities">';
                echo '</form>';
                
                // Check if a circle is selected
                if (isset($_GET['circle-id']) && is_numeric($_GET['circle-id'])) {
                    $selected_circle_id = intval($_GET['circle-id']);
                    $selected_circle = bcircles_get_circle($selected_circle_id);
                    
                    if ($selected_circle) {
                        // Display circle activities
                        echo '<h2>Circle Activities: ' . esc_html($selected_circle->name) . '</h2>';
                        
                        // You can customize the way circle activities are displayed here
                        //bp_activity_loop();
                    } else {
                        echo '<p>Invalid circle selected.</p>';
                    }
                }
            } else {
                echo '<p>You are not a member of any circles.</p>';
            }
        } else {
            echo '<p>Please log in to view your circles and activities.</p>';
        }
    
        return ob_get_clean();
    }
    add_shortcode('user_circles_and_activities', 'display_user_circles_and_activities_shortcode');

    —————-
    if the selected circle data can be displayed on the same screen or directed to main activity feed either would be good.

    -Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24645
    Brajesh Singh on #50767

    Hi Bill,
    Thank you for sharing the code!

    Please share more details/context about the goals this code is trying to achieve to help us understand and assist you.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 13
    Bill Perzeski on #50775
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24645
    Brajesh Singh on #50777
    This reply has been marked as private.
  • Participant
    Level: Initiated
    Posts: 13
    Bill Perzeski on #50850
    This reply has been marked as private.
  • Participant
    Level: Initiated
    Posts: 13
    Bill Perzeski on #50931

    Any updates?

  • Keymaster
    (BuddyDev Team)
    Posts: 24645
    Brajesh Singh on #50937

    Hi Bill,
    I am sorry for the delay. I had a look. The code provided above is not doing anything. It is simply adding a shortcode.

    BuddyBoss activity is heavility dependent on javascript and if you are trying to create a shortcode for activity listing, you need to consider that part.

    The changes you are looking(if we wanted to do it on directory/profile activity) will take couple of hours to code and test and is beyond our support!

    I will suggest hiring a developer to achieve the same.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved