WordCamp Europe 2023 Special Offer - Get 30% OFF any edition with coupon: WC30

My Account

Forums

Home Forums General How to override existing variables or creating custom variables

Viewing 3 reply threads
  • Author
    Posts
    • #174726
      Marco Michely
      Participant

      Hi there,

      in my projects I am using a custom settings page for having sme contact data in one place (created with Metabox.io).
      Now I want to use the e-mail field from this settings page as default form recipient.

      I would like to eighter override #blog_admin_email or to introduce a new custom variable for example #settings_site_email.

      Any ideas and hints how to do that?

      Thanks in advance.

    • #182701
      Mark Westguard
      Keymaster

      Hi Marco

      In our send email class we have this filter:

      $email_to = apply_filters('wsf_action_email_to', $email_to, $form, $submit);

      $email_to is an array of email addresses. You could use the wsf_action_email_to filter to change the recipient email address from the admin email address.

      For official support, please use our support page: https://wsform.com/support/

      Thanks

      Mark

    • #182855
      Marco Michely
      Participant

      Thanks a lot, Mark!

    • #182863
      Marco Michely
      Participant

      Here’s an easy solution:

      function mwe_action_mail_to( $email_to ) {
      
          $admin_email = get_bloginfo('admin_email');
      
          foreach($email_to as $key => $email) {
              if(str_contains($email, $admin_email)) {
                  $email_to[$key] = "My Name <my@domain.com>";
              }
          }
          
          return $email_to;
      
      }
      add_filter('wsf_action_email_to', 'mwe_action_mail_to');
Viewing 3 reply threads
  • You must be logged in to reply to this topic.

Login