• Resolved saberi02

    (@saberi02)


    Hi
    Thanks for develop very useful plugin.
    Can I send specified categories to separate channels ?
    categories A,B,C sent to sport_football Channel
    and
    categories D,E,F sent to sport_volleyball Channel

    best regards

Viewing 9 replies - 1 through 9 (of 9 total)
  • As of now, it’s not directly possible to configure it from settings page to make it work like that. May be in future :). But, the plugin has many useful filters, if you know little bit of PHP. You can make use of these filters to do exactly what you want.
    One such filter is wptelegram_post_to_chat_ids in get_chat_ids() method in includes/class-wptelegram-post-handler.php.
    If you need any help in such customizations, you may contact us at support@wptelegram.com

    Thread Starter saberi02

    (@saberi02)

    would you explain with example how can i use filters.
    thanks for quick answer.

    You can add this to functions.php of your active theme

    add_filter( 'wptelegram_post_to_chat_ids', 'wptelegram_post_category_to_channel', 10, 2 );
    function wptelegram_post_category_to_channel( $chat_ids, $post ) {
    	
    	$football_categories = array( 'A', 'B', 'C' );
    	$volleyball_categories = array( 'D', 'E', 'F' );
    
    	if ( has_category( $football_categories, $post ) ) {
    		$chat_ids = array( '@sport_football' );
    	} elseif ( has_category( $volleyball_categories, $post ) ) {
    		$chat_ids = array( '@sport_volleyball' );
    	}
    	return $chat_ids;
    }

    Don’t forget to change/correct the names of the categories and the channel usernames.
    Note: I have not tested the code, but that is the way to do it. Please take care about using that code in live/production environment.

    Thread Starter saberi02

    (@saberi02)

    i check it and let you know.
    tanx

    @saberi02 Did you manage to make it work the way you wanted?

    I have tested the code and it works. Feel free to contact again if you face any issues.

    Hi,
    Thanks for plugin very nice, I’ve another question on these topic.
    Can I send to different channels article filtered by Taxonomy
    If is it possible, would you explain with example?

    Very thanks and best regards

    @alcozz, it’s very simple.
    In above code, you can replace has_category() with has_term( $term, 'taxonomy-name', $post )
    Read more about has_term()

    thanks for the answer, I’ll try and let you know

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘sent different category to multi channel’ is closed to new replies.