Using the Organizer's featured image as the Event's featured image

Home Forums Calendar Products Events Calendar PRO Using the Organizer's featured image as the Event's featured image

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #127911
    Marc
    Participant

    Would it be possible to hack the plugin so that the organizer’s featured image is dynamically used as the event’s featured image? Any hints in the right direction would be appreciated.

    #128342
    Marc
    Participant

    Here is a very uneducated attempt. I’m sure I have some things really, really wrong. But figured I get something started.

    Here are the basics I need:
    * Function needs to run if post type = tribe_events
    * If the post has a featured image, it should do nothing
    * If the post does not have a featured image, it should look at what the event’s organizer is and take the featured image from that organizer post.
    * Save or update the post and it will assign a featured image based on above criteria

    Here’s my attempt for functions.php:

    /** Check if an Tribe Event post has a Post Thumbnail, if not set associated Tribe Organizer as Post Thumbnail */

    function organizer_featured() {

    if ( ‘tribe_events’ == get_post_type() ) {

    if ( has_post_thumbnail() ) {
    // nothing should happen
    }
    else {
    set_post_thumbnail($post, $thumbnail_id) {
    $post = tribe_get_organizer_id ();
    }
    }
    }
    add_action(‘the_post’, ‘organizer_featured’);
    add_action(‘save_post’, ‘organizer_featured’);
    add_action(‘draft_to_publish’, ‘organizer_featured’);
    add_action(‘new_to_publish’, ‘organizer_featured’);
    add_action(‘pending_to_publish’, ‘organizer_featured’);
    add_action(‘future_to_publish’, ‘organizer_featured’);

    #128371
    Brook
    Participant

    Howdy mcmvanbree,

    Is that code working properly for you? I am interested in adding it to my list of snippets along with a credit to you of course. While I have never seen someone request this before, it is an interesting customization and definitely might popup again. Thanks for sharing!

    – Brook

    #128614
    Marc
    Participant

    Thanks! I really don’t think this code works. I’m not a developer. But I wanted to try to figure out some of the basics, hoping that you guys would take it and fix it or give some pointers. I would love someone on the Tribe team to look at it and fix it.

    I agree it could be a very valuable addition to a useful snippet list. I post lots of events and use the featured image of event posts in a home page slider. It would be great not to have to upload individual images for each event, but rely on the organizer’s image.

    #129462
    Brook
    Participant

    Howdy mcmvanbree,

    I am sorry, after taking a closer look at your code I am seeing some syntax errors and such that would make it inoperable. it is a bit harder to spot such things with how our forum renders code.

    This modification probably makes the most sense as a filter (not an action) that kicks in anytime a tribe featured image is called. Then you would just have one WP Hook. If the image is not blank, then you would just return it. However if it is blank and definitely for an event, then you could return the organizer image if that is set. I hope that helps get you started down the right direction.

    You might also find it useful to write your code in a program like PHPStorm. That will point out any syntax errors in your code, and go a long way towards helping you write this snippet.

    Cheers!

    – Brook

    #129564
    Marc
    Participant

    I’m not going to figure this one out by myself… with the filter, I don’t know what hook to tie into. There’s a lot of other questions I have… Is this better?

    add_filter( ‘WHAT HOOK?’, ‘set_featured_event_image’, 1);

    function set_featured_event_image ( $featured_event_image ) {
    if ( get_post_type() == ‘tribe_events’) {
    if ( has_post_thumbnail() ) {
    $featured_event_image = $post_thumbnail_id
    } else {
    $featured_event_image = GRAB THE ORGANIZER THUMBNAIL?
    }
    }
    }
    return $featured_event_image;
    }

    #129568
    Marc
    Participant

    I realize you guys can’t respond to customizations all the time, but I figured this one would be very helpful for the community as well. As you mentioned, it would be a good addition to the code snippets. Could one of your developers do a quick fix to my code?

    #130163
    Brook
    Participant

    You are on the right track there.

    As you might be aware we do on occasion write complete snippet (instead of just instructions like I gave you) when we have seen multiple people request it; but, this is not actually part of the PRO support that we offer. Rather, it is something we do pro bono, as a way of giving back to our awesome users. Unfortunately we cannot afford to do this with every customization we see requested, only ones where we see a few users requesting it. Since you are the only person I have been able to find who wants this customization, I am afraid it currently falls outside of our gratis snippet design scope.

    If you would like to recommend to recommend this as a feature for our plugin please do so. Or, if you have the budget you can certainly hire someone. Even if you do not personally know someone whom you can hire, have no fear. We keep a list of freelancers who are quite capable of making changes on your behalf. You can obtain this list by emailing [email protected] and requesting it.

    Thank you for being understanding. If you have any questions, or are curious about our scope of support, please ask. Thanks again!

    – Brook

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Using the Organizer's featured image as the Event's featured image’ is closed to new replies.