Okay
  Public Ticket #2629081
Buddypress integration
Closed

Comments

  •  5
    Earl D started the conversation

    I am looking for documentation of the Buddypress integration to implement the group events calendar and events tab on Buddypress profile

    Thanks 

  •  894
    Zhivko replied

    Hi,

    It's pretty simple.

    1) Create new calendar or edit your existing one.

    2) Go to Front-End Visibility settings which basically means "Who can view the calendar on the front-end" and select your buddypress group from the list.

    3) Do the same for the Back-End Visibility ("Who can edit the calendar and its events") setting. Note super admins can see and edit the calendar regardless of this setting.

    That's it. Now events created in this calendar will be visible only to this Buddypress Group.


    Stachethemes Developer

  •  5
    Earl D replied

    ok look forward to deeper integration like activity post to the group feed when new event created.

    Also the group calendar not showing in the calendar list on the front end drop down. Any clues?


  •  894
    Zhivko replied

    Yes, that will be included in the future update. If you have additional suggestions do let us know.

    I assume your BP Calendar has no events? It must have at least one event in order to show up in the calendars' list.


    Stachethemes Developer

  •  5
    Earl D replied

    It does but maybe the page was being cached it is showing up now.

    Another suggestion would be the ability to add events from the Buddypress group page and an events tab on Buddypress user profile.

    Trying to do a work around right now but cannot find a shortcode for user event needed for the work around. Is there such a thing or another way to list registered user submitted events?

  •  894
    Zhivko replied

    There's filter by organizer_id but not by author id... I'll add this one in the next update.

    Meanwhile I've written small code that will allow you to filter by user id:

    /**
     * STEC MOD: Filters events by author id
     * 
     * Custom parameter: filter_by_user_id={id}
     * 
     * Example: [stachethemes_ec filter_by_user_id=1]
     */
    add_filter('stec_event_get_front_data', function($data) {
        $data['authorid'] = get_post_field('post_author', $data['id']);
        return $data;
    }); add_action('wp_footer', function() {     global $post;     if (!is_a($post, 'WP_Post') || !has_shortcode($post->post_content, 'stachethemes_ec')) {
            return;
        }
        ?>
        <script type="text/javascript">
            (function ($) {
                $(function () {
                    if (typeof $.stecExtend === 'undefined') {
                        return;
                    }                 $.stecExtend(function (m) {
                        var filteredEvents = [];
                        if (!m.glob.options.filter_by_user_id) {
                            return;
                        }                     $.each(m.calData.eventsPool, function () {
                            if (parseInt(this.authorid, 10) === parseInt(m.glob.options.filter_by_user_id, 10)) {
                                filteredEvents.push(this);
                            }
                        });                     m.calData.eventsPool = filteredEvents;                 }, 'onAddToEventsPool');
                });
            })(window.jQuery);
        </script>
        <?php
    });

    Place the code in your theme or child-theme functions.php file.

    After that you can use it in your shortcode like this:

    [stachethemes_ec filter_by_user_id=1]

    Where 1 for example is the user/author id.



    Stachethemes Developer

  •  5
    Earl D replied

    This looks great but I need it to read the current logged in user is there a string to input for that?

  •  894
    Zhivko replied

    Remove the code I've sent you and replace it with this one. 

    I've updated it to to include additional parameter.

    If you set filter_by_user_id to "current" it will set the id to the logged-in user id.

    Example:

    [stachethemes_ec filter_by_user_id=current]

    Updated Code:

    /**
     * STEC MOD: Filters events by author id
     * 
     * Custom parameter: filter_by_user_id={id}
     * 
     * Example: [stachethemes_ec filter_by_user_id=1]
     * 
     * Example: [stachethemes_ec filter_by_user_id=current]
     */
    add_filter('stec_event_get_front_data', function($data) {
        $data['authorid'] = get_post_field('post_author', $data['id']);
        return $data;
    });
    add_action('wp_footer', function() {
        global $post;
        if (!is_a($post, 'WP_Post') || !has_shortcode($post->post_content, 'stachethemes_ec')) {
            return;
        }
        ?>
        <script type="text/javascript">
            (function ($) {
                $(function () {
                    if (typeof $.stecExtend === 'undefined') {
                        return;
                    }
                    $.stecExtend(function (m) {
                        var filteredEvents = [];
                        var filterById;
                        if (!m.glob.options.filter_by_user_id) {
                            return;
                        }
                        filterById = 'current' === m.glob.options.filter_by_user_id ?
                                m.glob.options.userid :
                                parseInt(m.glob.options.filter_by_user_id, 10);
                        $.each(m.calData.eventsPool, function () {
                            if (parseInt(this.authorid, 10) === filterById) {
                                filteredEvents.push(this);
                            }
                        });
                        m.calData.eventsPool = filteredEvents;
                    }, 'onAddToEventsPool');
                });
            })(window.jQuery);
        </script>
        <?php
    });

    Stachethemes Developer