{"id":7415,"date":"2021-05-15T16:33:36","date_gmt":"2021-05-15T16:33:36","guid":{"rendered":"https:\/\/docs.campaignsuite.nl\/docs\/developers\/filters\/cs_validate_contact_account\/"},"modified":"2021-05-15T16:35:29","modified_gmt":"2021-05-15T16:35:29","slug":"cs_validate_contact_account","status":"publish","type":"docs","link":"https:\/\/docs.campaignsuite.nl\/en\/docs\/developers\/filters\/cs_validate_contact_account\/","title":{"rendered":"cs_validate_contact_account"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"7415\" class=\"elementor elementor-7415\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-cc4f945 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"cc4f945\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b6e6d53\" data-id=\"b6e6d53\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-40af3e3 elementor-widget elementor-widget-text-editor\" data-id=\"40af3e3\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<h4>Description<\/h4><p>This filter allows you to manipulate the contact and account array when this data is created just before a form is validated.<\/p><h4>Use<\/h4>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-68e5830 elementor-widget elementor-widget-docly_code_syntax_highlighter\" data-id=\"68e5830\" data-element_type=\"widget\" data-widget_type=\"docly_code_syntax_highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t                    <div class=\"docly-source-code prism\" data-lng-type=\"php\">\r\n\t\t\t<pre>\r\n\t\t\t\t<code class=\"language-php\">\r\n\t\t\t\t\tadd_filter( &#039;cs_validate_contact_account&#039;, &#039;custom_contact_account&#039; );\n\n\/\/You can also use a Gravity Forms form ID to target a specific form\nadd_filter( &#039;cs_validate_contact_account_6&#039;, &#039;custom_contact_account&#039; );\t\t\t\t<\/code>\r\n\t\t\t<\/pre>\r\n            <\/div>\r\n                \t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1b6a414 elementor-widget elementor-widget-text-editor\" data-id=\"1b6a414\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<h4>Parameters<\/h4><ul><li><strong> $contact_account (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Array\" target=\"_blank\" rel=\"noopener\"> array <\/a>) <\/strong><br \/>This array passes the displayed contact and account arrays. This value must be returned in the filter function.<\/li><li><strong> $payer (<a href=\"https:\/\/en.wikipedia.org\/wiki\/PHP_Data_Objects\" target=\"_blank\" rel=\"noopener\"> object <\/a>) <\/strong><br \/>This is the full object of the CampaignSuite Payer class. This object contains various additional information about the payer.<\/li><\/ul><h4>Example<\/h4>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-53091d8 elementor-widget elementor-widget-docly_code_syntax_highlighter\" data-id=\"53091d8\" data-element_type=\"widget\" data-widget_type=\"docly_code_syntax_highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t                    <div class=\"docly-source-code prism\" data-lng-type=\"php\">\r\n\t\t\t<pre>\r\n\t\t\t\t<code class=\"language-php\">\r\n\t\t\t\t\tadd_filter(&#039;cs_validate_contact_account&#039;, &#039;validate_contact_account&#039;, 10, 2);\nfunction validate_contact_account($contact_account, $payer)\n{\n    [$contact, $account] = $contact_account;\n    if (isset($contact[&#039;Phone&#039;]) &amp;&amp; !empty($contact[&#039;Phone&#039;])) {\n        if (isMobile($contact[&#039;Phone&#039;])) {\n            $contact[&#039;MobilePhone&#039;] = $contact[&#039;Phone&#039;];\n            unset($contact[&#039;Phone&#039;]);\n        }\n    }\n    \n    if ($payer-&gt;accountRecordType != &#039;Household&#039;) {\n        $contact[&#039;soco__Assign_Donations_to_Parent_Account__c&#039;] = true;\n    } else {\n        $contact[&#039;soco__Assign_Donations_to_Parent_Account__c&#039;] = false;\n    }\n    \n    return [$contact, $account];\n}\t\t\t\t<\/code>\r\n\t\t\t<\/pre>\r\n            <\/div>\r\n                \t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Description This filter allows you to manipulate the contact and account array when this data is created just before a form is validated. Use add_filter( &#039;cs_validate_contact_account&#039;, &#039;custom_contact_account&#039; ); \/\/You can also use a Gravity Forms form ID to target a specific form add_filter( &#039;cs_validate_contact_account_6&#039;, &#039;custom_contact_account&#039; ); Parameters $contact_account ( array ) This array passes the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":7407,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-7415","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs\/7415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/comments?post=7415"}],"version-history":[{"count":3,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs\/7415\/revisions"}],"predecessor-version":[{"id":7418,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs\/7415\/revisions\/7418"}],"up":[{"embeddable":true,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs\/7407"}],"wp:attachment":[{"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/media?parent=7415"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/doc_tag?post=7415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}