Okay
  Public Ticket #2590008
link profile
Closed

Comments

  •  2
    david started the conversation

    Hello Zhivko,

    I wonder if we can link the users who attended the event to theirs profiles?

  •  2
    david replied

    here 

  •  2
    david replied

    Hello Zhivko,

    any updates?

  •  2
    david replied

    Hello Zhivko,

    I wonder if we can link the users who attended the event to theirs profiles?

  •   david replied privately
  •  783
    Zhivko replied

    I'll check if this can be done and will let you know today.


    Stachethemes Developer

  •  783
    Zhivko replied

    Are you talking about buddypress profile?


    Stachethemes Developer

  •  2
    david replied

    User pro  

  •  783
    Zhivko replied

    The one in the admin panel?


    Stachethemes Developer

  •  2
  •  783
    Zhivko replied

    Or you mean the Author Page?


    Stachethemes Developer

  •  783
    Zhivko replied

    Unfortunately the code required is not very short...

    Place it in your child-theme functions.php file:

    /**
     * IN CALENDAR ATTENDEES TAB PROFILE LINK
     */
    add_filter('stec_event_get_front_data', function($data) {     $attendees = &$data['attendance'];
        if ($attendees) {
            foreach ($attendees as &$attendee) {
                $userid = $attendee->userid;
                if ($userid && $userid > 0) {
                    $profile_link           = get_edit_profile_url($userid);
                    $attendee->profile_link = $profile_link;
                }
            }
        }     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) {
                        m.$instance.on('onEventToggleOpen', function (e, data) {
                            setTimeout(function () {
                                if (data.event.attendance.length > 0) {
                                    $.each(data.event.attendance, function () {
                                        if (this.profile_link && this.userid) {
                                            let $attendeeName = data.$container.find('.stec-layout-event-inner-attendance-attendee-avatar[data-userid="' + this.userid + '"]').next('p');
                                            if ($attendeeName.find('a').length === 0) {
                                                let name = $attendeeName.text();
                                                $attendeeName.html('<a href="' + this.profile_link + '">' + name + '</a>');
                                            }
                                        }
                                    });
                                }
                            });
                        });
                    });
                });
            })(window.jQuery);
        </script>
        <?php
    }); /**
     * SINGLE PAGE ATTENDEES PROFILE LINK
     */
    add_action('stec_single_wp_footer', function($event) {     $profiles  = array();
        $attendees = $event->get_attendance();     if (!$attendees) {
            return;
        }     foreach ($attendees as $attendee) {
            $userid = $attendee->get_userid();         if ($userid && $userid > 0) {
                $profile_link                  = get_edit_profile_url($userid);
                $profiles['userid-' . $userid] = array(
                    'id'   => $userid,
                    'link' => $profile_link
                );
            }
        }
        
        if (!$profiles) {
            return;
        }
        ?>
        <script type="text/javascript">
            (function ($) {             if (stecSingleEvent.attendance.length > 0) {                 const profiles = <?php echo wp_json_encode($profiles); ?>                 $.each(stecSingleEvent.attendance, function () {
                        if (this.userid && profiles['userid-' + this.userid] && profiles['userid-' + this.userid].link) {
                            let $attendeeName = $('.stec-layout-single-attendance-attendee-avatar[data-userid="' + this.userid + '"]').next('p');
                            if ($attendeeName.find('a').length === 0) {
                                let name = $attendeeName.text();
                                $attendeeName.html('<a href="' + profiles['userid-' + this.userid].link + '">' + name + '</a>');
                            }
                        }
                    });
                }         })(window.jQuery);     </script>
        <?php
    });



    Stachethemes Developer

  •  2
    david replied

    /** * IN CALENDAR ATTENDEES TAB PROFILE LINK */
    add_filter('stec_event_get_front_data', function($data) { $attendees = &$data['attendance']; if ($attendees) { foreach ($attendees as &$attendee) { $userid = $attendee->userid; if ($userid && $userid > 0) { $profile_link = get_edit_profile_url($userid); $attendee->profile_link = $profile_link; } } } return $data;
    });
    add_action('wp_footer', function() { global $post; if (!is_a($post, 'WP_Post') || !has_shortcode($post->post_content, 'stachethemes_ec')) { return; } ?>     

  •  2
    david replied

    Or you mean the Author Page?

    YES :=) 


    and sorry but it is not working 

  •  783
    Zhivko replied

    Then the code should look like this:

    /**
     * IN CALENDAR ATTENDEES TAB PROFILE LINK
     */
    add_filter('stec_event_get_front_data', function($data) {
        $attendees = &$data['attendance'];
        if ($attendees) {
            foreach ($attendees as &$attendee) {
                $userid = $attendee->userid;
                if ($userid && $userid > 0) {
                    $profile_link           = get_author_posts_url($userid);
                    $attendee->profile_link = $profile_link;
                }
            }
        }
        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) {
                        m.$instance.on('onEventToggleOpen', function (e, data) {
                            setTimeout(function () {
                                if (data.event.attendance.length > 0) {
                                    $.each(data.event.attendance, function () {
                                        if (this.profile_link && this.userid) {
                                            let $attendeeName = data.$container.find('.stec-layout-event-inner-attendance-attendee-avatar[data-userid="' + this.userid + '"]').next('p');
                                            if ($attendeeName.find('a').length === 0) {
                                                let name = $attendeeName.text();
                                                $attendeeName.html('<a href="' + this.profile_link + '">' + name + '</a>');
                                            }
                                        }
                                    });
                                }
                            });
                        });
                    });
                });
            })(window.jQuery);
        </script>
        <?php
    });
    /**
     * SINGLE PAGE ATTENDEES PROFILE LINK
     */
    add_action('stec_single_wp_footer', function($event) {
        $profiles  = array();
        $attendees = $event->get_attendance();
        if (!$attendees) {
            return;
        }
        foreach ($attendees as $attendee) {
            $userid = $attendee->get_userid();
            if ($userid && $userid > 0) {
                $profile_link                  = get_author_posts_url($userid);
                $profiles['userid-' . $userid] = array(
                    'id'   => $userid,
                    'link' => $profile_link
                );
            }
        }
        
        if (!$profiles) {
            return;
        }
        ?>
        <script type="text/javascript">
            (function ($) {
                if (stecSingleEvent.attendance.length > 0) {
                    const profiles = <?php echo wp_json_encode($profiles); ?>
                    $.each(stecSingleEvent.attendance, function () {
                        if (this.userid && profiles['userid-' + this.userid] && profiles['userid-' + this.userid].link) {
                            let $attendeeName = $('.stec-layout-single-attendance-attendee-avatar[data-userid="' + this.userid + '"]').next('p');
                            if ($attendeeName.find('a').length === 0) {
                                let name = $attendeeName.text();
                                $attendeeName.html('<a href="' + profiles['userid-' + this.userid].link + '">' + name + '</a>');
                            }
                        }
                    });
                }
            })(window.jQuery);
        </script>
        <?php
    });

    Make sure you've placed it in your active theme functions.php file. 

    And clear your browser cache on the calendar page (ctrl + f5 on chrome).

    Also check your browser console (F12 on chrome) for javascript errors just in case.


    Stachethemes Developer

  •  2
    david replied

    THANKS !!!!!!!!! it works great