Support » Plugin: GamiPress » Create Custom Event for post with specific meta_key value

  • Resolved isabelpinhel


    Hi there,

    I would like to assign points to users who post a custom post type (‘job_listing’) where the meta_key ‘_case27_listing_type’ has the value ‘probiotics’.
    I wrote the code below based on your documentation but it’s not working. If I remove $listing_type == ‘probiotics’ from the if statement on the listener then it works, ie. assigns points, but targets all custom post types with any value of ‘_case27_listing_type’. Where am I going wrong?

    add_filter( 'gamipress_activity_triggers', 'activity_trigger_listings' );
    function activity_trigger_listings( $triggers ) {
        // Replace this with the CPT you want, for example: event
        $listing = 'job_listing';
        $post_type = get_post_type_object( $listing );
        $triggers[__( 'Listings', 'gamipress' )] = array(
            'gamipress_publish_listing' => sprintf( __( 'Publish a %s', 'gamipress' ), $post_type->labels->singular_name ),
            'gamipress_delete_listing' => sprintf( __( 'Delete a %s', 'gamipress' ), $post_type->labels->singular_name ),
        return $triggers;
    add_action( 'transition_post_status', 'listener_trigger_listings', 10, 4 );
    function listener_trigger_listings( $new_status, $old_status, $post, $listing_type ) {
        global $post;
        $post_id = $post->ID;
     	$listing_type = get_post_meta( $post_id, '_case27_listing_type', true );
        // Check if post status transition come to publish
        if ( ( $new_status == 'publish' ) && ( $old_status != 'publish' ) && ( $listing_type == 'probiotics' ) ) {
            // Trigger content publishing actions
            gamipress_trigger_event( array(
                'event'      => 'gamipress_publish_listing',
                'user_id'    => get_current_user_id(),
            ) );

    Any help you can provide would be greatly appreciated.


Viewing 1 replies (of 1 total)
  • Plugin Author rubengc


    Hi @isabelpinhel

    I’m sorry by we don’t offer support for customizations like that since our main focus is the development and maintenance of GamiPress and all official add-ons

    Anyway, any WordPress custom development agency or freelance can handle it for you

    If you don’t know one, we recommend to check our list of trusted experts that can estimate any type of job for you here:

    Best regards

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.