Forum Replies Created

Viewing 1 replies (of 1 total)
  • cat50303

    (@cat50303)

    Hello,

    I found that just comment out the if ( $result['mail_sent'] )

    it’ll works.

    full php attached. Just try it.

    /**
     * Adds new event that send notification to Slack channel
     * when someone sent message through Contact Form 7.
     *
     * @param  array $events
     * @return array
     *
     * @filter slack_get_events
     */
    function wp_slack_wpcf7_submit( $events ) {
    	$events['wpcf7_submit'] = array(
    		// Action in Gravity Forms to hook in to get the message.
    		'action' => 'wpcf7_submit',
    
    		// Description appears in integration setting.
    		'description' => __( 'When someone sent message through Contact Form 7', 'slack' ),
    
    		// Message to deliver to channel. Returns false will prevent
    		// notification delivery.
    		'message' => function( $form, $result ) {
    
    			// @todo: Once attachment is supported in Slack
    			// we can send payload with nicely formatted message
    			// without relying on mail_sent result.
    			//if ( $result['mail_sent'] ) {
    				return apply_filters( 'slack_wpcf7_submit_message',
    					sprintf(
    						__( '有人從 *%s* 聯絡表單送出訊息,請至Gmail收信!', 'slack' ),
    						$form->title
    					),
    
    					$form,
    					$result
    				);
    			//}
    
    			return false;
    		}
    	);
    
    	return $events;
    }
    add_filter( 'slack_get_events', 'wp_slack_wpcf7_submit' );
Viewing 1 replies (of 1 total)