Import and show facebook eventlink in description

Home Forums Calendar Products Event Aggregator Import and show facebook eventlink in description

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1086900
    Tobias
    Participant

    Hi,

    is it possible to add the eventlink as the ‘Event Link’ in the description?

    thx!

    #1087194
    George
    Participant

    Hey Tobias,

    It’s unfortunately not easily possible to do this selectively, but I did write a snippet of code here for you that should help quite a bit—this will make events imported from Facebook link directly to the Facebook event on facebook.com.

    If the event is NOT imported from Facebook, it will just link to its normal single-event page on your site.

    Try adding this code to your theme’s functions.php file and let me know if it helps!


    add_filter( 'tribe_get_event_link', 'tribe_maybe_make_permalinks_fb_links', 10, 3 );

    function tribe_maybe_make_permalinks_fb_links( $link, $postId, $full_link ) {

    $event_id = 0;

    if ( $postId instanceof WP_Post ) {
    $event_id = absint( $postId->ID );
    }

    $event_id = ( ! $event_id ? get_the_ID() : $event_id );
    $meta = get_post_meta( $event_id );

    if ( ! isset( $meta['_EventOrigin'][0] ) || 'facebook-importer' !== $meta['_EventOrigin'][0] )
    return $link;

    if ( empty( $meta['_FacebookID'][0] ) )
    return $link;

    return sprintf( 'http://www.facebook.com/events/%s', absint( $meta['_FacebookID'][0] ) );
    }

    #1087637
    Tobias
    Participant

    Hi George,

    thx for your help.
    There might be an issue within that line:
    if ( $postId instanceof WP_Post ) {
    $event_id = absint( $postId->ID );
    }
    Got it working, though. But there might be a missunderständing.
    What it does right now, is linking directly to facebook, if it is an import.
    What I want to have, is just a link shown in the description, so the user can go
    to facebook and join the event. Like that (“Website:”):
    http://www.club-kreuzkeller.de/wordpress/event/the-awakening-2/

    I have to do that manually, atm.

    Thx,

    Tobi

    #1087871
    George
    Participant

    Hi Tobi,

    If you tweak the code I shared to this, it will add a “View on Facebook” link after event description content with a link to the event on Facebook:


    add_filter( 'the_content', 'tribe_auto_add_FB_link_after_content' );

    function tribe_auto_add_FB_link_after_content( $content ) {

    if ( ! tribe_is_event() )
    return $content;

    $meta = get_post_meta( get_the_ID() );

    if ( ! isset( $meta['_EventOrigin'][0] ) || 'facebook-importer' !== $meta['_EventOrigin'][0] )
    return $content;

    if ( empty( $meta['_FacebookID'][0] ) )
    return $content;

    return $content . sprintf( '
    View on Facebook', absint( $meta['_FacebookID'][0] ) );
    }

    This will not add the link in Month View tooltips, for example, or on excerpts—only after single-event descriptions. If you would like to add the link to those other locations, that is unfortunately a more complicated customization and is too far outside the scope of our support for further code-customizing assistance.

    I hope this all helps regardless, and wish you the best of luck with your code customizing!

    Cheers,
    George

    #1089563
    Tobias
    Participant

    Hi George,

    thx for your help. Sorry for bothering you again… I definitely understand when this runs out of the regular support.
    I give it another try, though 🙂
    Your Code gives back the ‘View on Facebook’, but no link, not even hidden in some wrong html.
    meta[‘_FacebookID’][0] gives back the Event-ID, but couldn’t get i working anyway, since the whole thing is somehow too large for me.
    Somehow or other, the whole thing might be needed by more useres, to make clients go to facebook and join the events.
    Maybe a new Version-Feature..?

    Thx,
    Tobias

    #1090257
    George
    Participant

    Hi Tobias,

    Thanks for reaching out. One thing I noticed here is that the support forum’s security features here have stripped some of the characters in my original code!

    So, if you copied and pasted the code from these forums into your site, that is why the “view on Facebook” link might be working.

    Instead of using the code on this forum thread, I have pasted the ACCURATE and COMPLETE code into a Gist here → https://git.io/vawLa

    Get rid of the original code you copied from this thread; and instead, replace it with the code from that Gist.

    That might help!

    Cheers,
    George

    #1091553
    Tobias
    Participant

    Thx George,

    works perfect!

    Cheers – Tobi

    #1091582
    George
    Participant

    Glad to hear it—best of luck with your project!

    Sincerely,
    George

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Import and show facebook eventlink in description’ is closed to new replies.