[{"data":1,"prerenderedAt":832},["ShallowReactive",2],{"docs-page-\u002Fdocs\u002Fb418-tg-cf7\u002Fhooks":3,"docs-navigation":796},{"id":4,"title":5,"body":6,"description":789,"extension":790,"meta":791,"navigation":288,"path":792,"seo":793,"stem":794,"__hash__":795},"docs\u002Fdocs\u002Fb418-tg-cf7\u002F5.hooks.md","Developer hooks",{"type":7,"value":8,"toc":776},"minimark",[9,13,17,22,103,107,140,144,149,158,316,320,330,409,416,420,474,478,483,605,626,630,639,700,704,731,735,741,772],[10,11,5],"h1",{"id":12},"developer-hooks",[14,15,16],"p",{},"The plugin is extensible by design: every important step of the pipeline runs through a WordPress filter or action. This is the same API the Pro add-on builds on.",[18,19,21],"h2",{"id":20},"filters","Filters",[23,24,25,38],"table",{},[26,27,28],"thead",{},[29,30,31,35],"tr",{},[32,33,34],"th",{},"Filter",[32,36,37],{},"Purpose",[39,40,41,53,63,73,83,93],"tbody",{},[29,42,43,50],{},[44,45,46],"td",{},[47,48,49],"code",{},"b418_wp_tg_cf7_should_send",[44,51,52],{},"Last-chance veto before a connection fires",[29,54,55,60],{},[44,56,57],{},[47,58,59],{},"b418_wp_tg_cf7_message_text",[44,61,62],{},"Modify the final rendered message text",[29,64,65,70],{},[44,66,67],{},[47,68,69],{},"b418_wp_tg_cf7_placeholders",[44,71,72],{},"Add or change template placeholder values",[29,74,75,80],{},[44,76,77],{},[47,78,79],{},"b418_wp_tg_cf7_default_template",[44,81,82],{},"Change the built-in default template body",[29,84,85,90],{},[44,86,87],{},[47,88,89],{},"b418_wp_tg_cf7_send_args",[44,91,92],{},"Modify the Telegram API request arguments",[29,94,95,100],{},[44,96,97],{},[47,98,99],{},"b418_wp_tg_cf7_log_max_entries",[44,101,102],{},"Change how many activity-log entries are kept (default 50)",[18,104,106],{"id":105},"actions","Actions",[23,108,109,118],{},[26,110,111],{},[29,112,113,116],{},[32,114,115],{},"Action",[32,117,37],{},[39,119,120,130],{},[29,121,122,127],{},[44,123,124],{},[47,125,126],{},"b418_wp_tg_cf7_loaded",[44,128,129],{},"Fires once the plugin has fully booted — the entry point for add-ons",[29,131,132,137],{},[44,133,134],{},[47,135,136],{},"b418_wp_tg_cf7_after_send",[44,138,139],{},"Fires after each Telegram delivery attempt",[18,141,143],{"id":142},"examples","Examples",[145,146,148],"h3",{"id":147},"conditionally-skip-sending","Conditionally skip sending",[14,150,151,153,154,157],{},[47,152,49],{}," receives the routing rule, the form, and the submission — return ",[47,155,156],{},"false"," to skip that connection for this submission:",[159,160,165],"pre",{"className":161,"code":162,"language":163,"meta":164,"style":164},"language-php shiki shiki-themes github-dark","add_filter( 'b418_wp_tg_cf7_should_send', function ( $send, $rule, $contact_form, $submission ) {\n    \u002F\u002F Skip Telegram notifications for a specific form outside business hours.\n    if ( 123 === (int) $contact_form->id() && (int) wp_date( 'G' ) \u003C 9 ) {\n        return false;\n    }\n\n    return $send;\n}, 10, 4 );\n","php","",[47,166,167,194,201,265,277,283,290,299],{"__ignoreMap":164},[168,169,172,176,180,184,187,191],"span",{"class":170,"line":171},"line",1,[168,173,175],{"class":174},"svObZ","add_filter",[168,177,179],{"class":178},"s95oV","( ",[168,181,183],{"class":182},"sU2Wk","'b418_wp_tg_cf7_should_send'",[168,185,186],{"class":178},", ",[168,188,190],{"class":189},"snl16","function",[168,192,193],{"class":178}," ( $send, $rule, $contact_form, $submission ) {\n",[168,195,197],{"class":170,"line":196},2,[168,198,200],{"class":199},"sAwPA","    \u002F\u002F Skip Telegram notifications for a specific form outside business hours.\n",[168,202,204,207,210,214,217,220,223,226,229,232,235,238,240,242,245,248,250,253,256,259,262],{"class":170,"line":203},3,[168,205,206],{"class":189},"    if",[168,208,209],{"class":178}," ( ",[168,211,213],{"class":212},"sDLfK","123",[168,215,216],{"class":189}," ===",[168,218,219],{"class":178}," (",[168,221,222],{"class":189},"int",[168,224,225],{"class":178},") $contact_form",[168,227,228],{"class":189},"->",[168,230,231],{"class":174},"id",[168,233,234],{"class":178},"() ",[168,236,237],{"class":189},"&&",[168,239,219],{"class":178},[168,241,222],{"class":189},[168,243,244],{"class":178},") ",[168,246,247],{"class":174},"wp_date",[168,249,179],{"class":178},[168,251,252],{"class":182},"'G'",[168,254,255],{"class":178}," ) ",[168,257,258],{"class":189},"\u003C",[168,260,261],{"class":212}," 9",[168,263,264],{"class":178}," ) {\n",[168,266,268,271,274],{"class":170,"line":267},4,[168,269,270],{"class":189},"        return",[168,272,273],{"class":212}," false",[168,275,276],{"class":178},";\n",[168,278,280],{"class":170,"line":279},5,[168,281,282],{"class":178},"    }\n",[168,284,286],{"class":170,"line":285},6,[168,287,289],{"emptyLinePlaceholder":288},true,"\n",[168,291,293,296],{"class":170,"line":292},7,[168,294,295],{"class":189},"    return",[168,297,298],{"class":178}," $send;\n",[168,300,302,305,308,310,313],{"class":170,"line":301},8,[168,303,304],{"class":178},"}, ",[168,306,307],{"class":212},"10",[168,309,186],{"class":178},[168,311,312],{"class":212},"4",[168,314,315],{"class":178}," );\n",[145,317,319],{"id":318},"add-a-custom-template-placeholder","Add a custom template placeholder",[14,321,322,323,325,326,329],{},"Values returned from ",[47,324,69],{}," become ",[47,327,328],{},"[tag]"," replacements in every template:",[159,331,333],{"className":161,"code":332,"language":163,"meta":164,"style":164},"add_filter( 'b418_wp_tg_cf7_placeholders', function ( $placeholders, $form, $submission ) {\n    $placeholders['_referrer'] = (string) $submission->get_meta( 'referer' );\n\n    return $placeholders;\n}, 10, 3 );\n",[47,334,335,351,385,389,396],{"__ignoreMap":164},[168,336,337,339,341,344,346,348],{"class":170,"line":171},[168,338,175],{"class":174},[168,340,179],{"class":178},[168,342,343],{"class":182},"'b418_wp_tg_cf7_placeholders'",[168,345,186],{"class":178},[168,347,190],{"class":189},[168,349,350],{"class":178}," ( $placeholders, $form, $submission ) {\n",[168,352,353,356,359,362,365,367,370,373,375,378,380,383],{"class":170,"line":196},[168,354,355],{"class":178},"    $placeholders[",[168,357,358],{"class":182},"'_referrer'",[168,360,361],{"class":178},"] ",[168,363,364],{"class":189},"=",[168,366,219],{"class":178},[168,368,369],{"class":189},"string",[168,371,372],{"class":178},") $submission",[168,374,228],{"class":189},[168,376,377],{"class":174},"get_meta",[168,379,179],{"class":178},[168,381,382],{"class":182},"'referer'",[168,384,315],{"class":178},[168,386,387],{"class":170,"line":203},[168,388,289],{"emptyLinePlaceholder":288},[168,390,391,393],{"class":170,"line":267},[168,392,295],{"class":189},[168,394,395],{"class":178}," $placeholders;\n",[168,397,398,400,402,404,407],{"class":170,"line":279},[168,399,304],{"class":178},[168,401,307],{"class":212},[168,403,186],{"class":178},[168,405,406],{"class":212},"3",[168,408,315],{"class":178},[14,410,411,412,415],{},"Now ",[47,413,414],{},"[_referrer]"," works in any template.",[145,417,419],{"id":418},"modify-the-final-message-text","Modify the final message text",[159,421,423],{"className":161,"code":422,"language":163,"meta":164,"style":164},"add_filter( 'b418_wp_tg_cf7_message_text', function ( $text, $rule, $contact_form, $submission ) {\n    return $text . \"\\n\\n#leads\";\n}, 10, 4 );\n",[47,424,425,441,462],{"__ignoreMap":164},[168,426,427,429,431,434,436,438],{"class":170,"line":171},[168,428,175],{"class":174},[168,430,179],{"class":178},[168,432,433],{"class":182},"'b418_wp_tg_cf7_message_text'",[168,435,186],{"class":178},[168,437,190],{"class":189},[168,439,440],{"class":178}," ( $text, $rule, $contact_form, $submission ) {\n",[168,442,443,445,448,451,454,457,460],{"class":170,"line":196},[168,444,295],{"class":189},[168,446,447],{"class":178}," $text ",[168,449,450],{"class":189},".",[168,452,453],{"class":182}," \"",[168,455,456],{"class":212},"\\n\\n",[168,458,459],{"class":182},"#leads\"",[168,461,276],{"class":178},[168,463,464,466,468,470,472],{"class":170,"line":203},[168,465,304],{"class":178},[168,467,307],{"class":212},[168,469,186],{"class":178},[168,471,312],{"class":212},[168,473,315],{"class":178},[145,475,477],{"id":476},"react-to-a-delivery","React to a delivery",[14,479,480,482],{},[47,481,136],{}," fires for every chat a message was attempted to, with the raw Telegram API response and full context:",[159,484,486],{"className":161,"code":485,"language":163,"meta":164,"style":164},"add_action( 'b418_wp_tg_cf7_after_send', function ( $result, $rule, $chat, $bot, $submission, $context ) {\n    if ( empty( $result['ok'] ) ) {\n        error_log( sprintf(\n            'Telegram delivery failed for \"%s\" → %s: %s',\n            $context['form_title'],\n            $chat['name'],\n            $result['description'] ?? 'unknown error'\n        ) );\n    }\n}, 10, 6 );\n",[47,487,488,505,523,536,544,555,565,581,586,591],{"__ignoreMap":164},[168,489,490,493,495,498,500,502],{"class":170,"line":171},[168,491,492],{"class":174},"add_action",[168,494,179],{"class":178},[168,496,497],{"class":182},"'b418_wp_tg_cf7_after_send'",[168,499,186],{"class":178},[168,501,190],{"class":189},[168,503,504],{"class":178}," ( $result, $rule, $chat, $bot, $submission, $context ) {\n",[168,506,507,509,511,514,517,520],{"class":170,"line":196},[168,508,206],{"class":189},[168,510,209],{"class":178},[168,512,513],{"class":212},"empty",[168,515,516],{"class":178},"( $result[",[168,518,519],{"class":182},"'ok'",[168,521,522],{"class":178},"] ) ) {\n",[168,524,525,528,530,533],{"class":170,"line":203},[168,526,527],{"class":212},"        error_log",[168,529,179],{"class":178},[168,531,532],{"class":212},"sprintf",[168,534,535],{"class":178},"(\n",[168,537,538,541],{"class":170,"line":267},[168,539,540],{"class":182},"            'Telegram delivery failed for \"%s\" → %s: %s'",[168,542,543],{"class":178},",\n",[168,545,546,549,552],{"class":170,"line":279},[168,547,548],{"class":178},"            $context[",[168,550,551],{"class":182},"'form_title'",[168,553,554],{"class":178},"],\n",[168,556,557,560,563],{"class":170,"line":285},[168,558,559],{"class":178},"            $chat[",[168,561,562],{"class":182},"'name'",[168,564,554],{"class":178},[168,566,567,570,573,575,578],{"class":170,"line":292},[168,568,569],{"class":178},"            $result[",[168,571,572],{"class":182},"'description'",[168,574,361],{"class":178},[168,576,577],{"class":189},"??",[168,579,580],{"class":182}," 'unknown error'\n",[168,582,583],{"class":170,"line":301},[168,584,585],{"class":178},"        ) );\n",[168,587,589],{"class":170,"line":588},9,[168,590,282],{"class":178},[168,592,594,596,598,600,603],{"class":170,"line":593},10,[168,595,304],{"class":178},[168,597,307],{"class":212},[168,599,186],{"class":178},[168,601,602],{"class":212},"6",[168,604,315],{"class":178},[14,606,607,608,611,612,186,615,186,618,621,622,625],{},"The ",[47,609,610],{},"$context"," array contains the rendered ",[47,613,614],{},"text",[47,616,617],{},"parse_mode",[47,619,620],{},"form_id",", and ",[47,623,624],{},"form_title"," — enough to record or resend the delivery without holding a submission reference.",[145,627,629],{"id":628},"tweak-the-telegram-api-request","Tweak the Telegram API request",[14,631,632,634,635,638],{},[47,633,89],{}," filters the argument array passed to the Telegram ",[47,636,637],{},"sendMessage"," call — for example, to disable link previews:",[159,640,642],{"className":161,"code":641,"language":163,"meta":164,"style":164},"add_filter( 'b418_wp_tg_cf7_send_args', function ( $args, $chat, $context ) {\n    $args['disable_web_page_preview'] = true;\n\n    return $args;\n}, 10, 3 );\n",[47,643,644,660,677,681,688],{"__ignoreMap":164},[168,645,646,648,650,653,655,657],{"class":170,"line":171},[168,647,175],{"class":174},[168,649,179],{"class":178},[168,651,652],{"class":182},"'b418_wp_tg_cf7_send_args'",[168,654,186],{"class":178},[168,656,190],{"class":189},[168,658,659],{"class":178}," ( $args, $chat, $context ) {\n",[168,661,662,665,668,670,672,675],{"class":170,"line":196},[168,663,664],{"class":178},"    $args[",[168,666,667],{"class":182},"'disable_web_page_preview'",[168,669,361],{"class":178},[168,671,364],{"class":189},[168,673,674],{"class":212}," true",[168,676,276],{"class":178},[168,678,679],{"class":170,"line":203},[168,680,289],{"emptyLinePlaceholder":288},[168,682,683,685],{"class":170,"line":267},[168,684,295],{"class":189},[168,686,687],{"class":178}," $args;\n",[168,689,690,692,694,696,698],{"class":170,"line":279},[168,691,304],{"class":178},[168,693,307],{"class":212},[168,695,186],{"class":178},[168,697,406],{"class":212},[168,699,315],{"class":178},[145,701,703],{"id":702},"keep-a-longer-activity-log","Keep a longer activity log",[159,705,707],{"className":161,"code":706,"language":163,"meta":164,"style":164},"add_filter( 'b418_wp_tg_cf7_log_max_entries', fn () => 200 );\n",[47,708,709],{"__ignoreMap":164},[168,710,711,713,715,718,720,723,726,729],{"class":170,"line":171},[168,712,175],{"class":174},[168,714,179],{"class":178},[168,716,717],{"class":182},"'b418_wp_tg_cf7_log_max_entries'",[168,719,186],{"class":178},[168,721,722],{"class":189},"fn",[168,724,725],{"class":178}," () => ",[168,727,728],{"class":212},"200",[168,730,315],{"class":178},[18,732,734],{"id":733},"boot-order","Boot order",[14,736,737,738,740],{},"If your extension needs the plugin's classes, hook ",[47,739,126],{}," — it fires once the plugin has fully initialized:",[159,742,744],{"className":161,"code":743,"language":163,"meta":164,"style":164},"add_action( 'b418_wp_tg_cf7_loaded', function () {\n    \u002F\u002F Safe to register your filters\u002Factions here.\n} );\n",[47,745,746,762,767],{"__ignoreMap":164},[168,747,748,750,752,755,757,759],{"class":170,"line":171},[168,749,492],{"class":174},[168,751,179],{"class":178},[168,753,754],{"class":182},"'b418_wp_tg_cf7_loaded'",[168,756,186],{"class":178},[168,758,190],{"class":189},[168,760,761],{"class":178}," () {\n",[168,763,764],{"class":170,"line":196},[168,765,766],{"class":199},"    \u002F\u002F Safe to register your filters\u002Factions here.\n",[168,768,769],{"class":170,"line":203},[168,770,771],{"class":178},"} );\n",[773,774,775],"style",{},"html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":164,"searchDepth":196,"depth":196,"links":777},[778,779,780,788],{"id":20,"depth":196,"text":21},{"id":105,"depth":196,"text":106},{"id":142,"depth":196,"text":143,"children":781},[782,783,784,785,786,787],{"id":147,"depth":203,"text":148},{"id":318,"depth":203,"text":319},{"id":418,"depth":203,"text":419},{"id":476,"depth":203,"text":477},{"id":628,"depth":203,"text":629},{"id":702,"depth":203,"text":703},{"id":733,"depth":196,"text":734},"Filters and actions for extending B418 Telegram for Contact Form 7 — conditional sending, custom placeholders, delivery callbacks, and more.","md",{},"\u002Fdocs\u002Fb418-tg-cf7\u002Fhooks",{"title":5,"description":789},"docs\u002Fb418-tg-cf7\u002F5.hooks","whhtwj-_jHh_FHnfYkmTm6-N6ggX5M-KUfMGh6DZZZo",[797],{"title":798,"path":799,"stem":800,"children":801},"Docs","\u002Fdocs","docs",[802,805],{"title":803,"path":799,"stem":804},"Overview","docs\u002Findex",{"title":806,"path":807,"stem":808,"children":809,"page":831},"Telegram for CF7","\u002Fdocs\u002Fb418-tg-cf7","docs\u002Fb418-tg-cf7",[810,814,818,822,826,827],{"title":811,"path":812,"stem":813},"Getting started","\u002Fdocs\u002Fb418-tg-cf7\u002Fgetting-started","docs\u002Fb418-tg-cf7\u002F1.getting-started",{"title":815,"path":816,"stem":817},"Bots & chats","\u002Fdocs\u002Fb418-tg-cf7\u002Fbots-and-chats","docs\u002Fb418-tg-cf7\u002F2.bots-and-chats",{"title":819,"path":820,"stem":821},"Connections & routing","\u002Fdocs\u002Fb418-tg-cf7\u002Fconnections","docs\u002Fb418-tg-cf7\u002F3.connections",{"title":823,"path":824,"stem":825},"Message templates","\u002Fdocs\u002Fb418-tg-cf7\u002Fmessage-templates","docs\u002Fb418-tg-cf7\u002F4.message-templates",{"title":5,"path":792,"stem":794},{"title":828,"path":829,"stem":830},"FAQ & troubleshooting","\u002Fdocs\u002Fb418-tg-cf7\u002Ffaq","docs\u002Fb418-tg-cf7\u002F6.faq",false,1784301861415]