Support » Plugin: Getwid - Gutenberg Blocks » Changing Getwid contact form recipient

  • Resolved videostudio1

    (@videostudio1)


    I’m having a hard time figuring out a way to change the recipient email for the Getwid contact form block without having to change the WordPress admin email…
    I need this because I’m developing a site for a client, and the emails should be sent to him, but I need to keep my address for the admin email.

    Is there a way to change it? Even a function in the child theme would be okay if there aren’t other ways. I want to avoid the installation of a contact form plugin if possible.

    Thanks

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author MotoPress

    (@motopress)

    Hi @videostudio1,
    Thank you for your question. Unfortunately there is not an option to override plugin and change email address of recipient. As an option you may add separate account of Administrator for you keeping the email address of your customer there in WordPress settings.
    We will keep your request in mind and will do our best to add an option to indicate custom email of recipient in one of the next updates. Thanks.

    That sucks… I can’t put their email as admin email because they would receive all the WordPress emails that I should receive (regarding updates, problems etc.).

    What about this part inside getwid/includes/blocks/contact-form.php?

        private function send_mail( $data ) {
    
            $to      = get_option( 'admin_email' );
            $subject = empty( $data['subject'] ) ? sprintf( __( 'This e-mail was sent from a contact form on %s', 'getwid' ), get_option( 'blogname' ) ) : trim( $data[ 'subject' ] );
        
            $email   = trim( $data[ 'email' ] );
            $name    = stripslashes( $data[ 'name' ] );
            $message = stripslashes( $data[ 'message' ] );
            $body = $message;

    Isn’t there a way to override “admin_email” with a function? Please let me know.
    Otherwise I guess I will have to install a plugin :/

    Thanks

    Plugin Author MotoPress

    (@motopress)

    Hi @videostudio1,

    Thank you for your reply. I’ve managed to override it using the filter below:

    //Fires authenticated Ajax actions for logged-in users.
    add_action( 'wp_ajax_getwid_send_mail', 'mytheme_wp_ajax_getwid_send_mail' );
    
    //Fires non-authenticated Ajax actions for logged-out users.
    add_action( 'wp_ajax_nopriv_getwid_send_mail', 'mytheme_wp_ajax_getwid_send_mail' );
    
    //Filter admin_email once.
    function mytheme_wp_ajax_getwid_send_mail(){
        add_filter('option_admin_email', 'mytheme_getwid_change_admin_email');
    }
    
    //Set new recipient address
    function mytheme_getwid_change_admin_email( $value ) {
        return "new-email@mail.com";
    }

    Let me know if it helps.

    It works!

    Thank you so much for the quick response.

    Looking forward for an update that will integrate this option inside Gutenberg!

    Plugin Author MotoPress

    (@motopress)

    Thank you for your feedback 😉

    +1 to please integrate this into the GUI form editor, pretty please. That would allow to use different emails for different forms on different pages, as well.

    Plugin Support Dmytro

    (@dimned)

    Hi @berteh,
    Thanks for your feedback. Your request is added to our list of features.

    aluo

    (@aluo)

    Hi @motopress,

    Could you tell me which file should I put the code in? I tried to add the following code in wp-content/plugins/getwid/includes/functions.php, but I got an error message “There was an error trying to send your message. Please try again later.” when I tested the contact form. Thanks.

    //Fires authenticated Ajax actions for logged-in users.
    add_action( 'wp_ajax_getwid_send_mail', 'mytheme_wp_ajax_getwid_send_mail' );
    
    //Fires non-authenticated Ajax actions for logged-out users.
    add_action( 'wp_ajax_nopriv_getwid_send_mail', 'mytheme_wp_ajax_getwid_send_mail' );
    
    //Filter admin_email once.
    function mytheme_wp_ajax_getwid_send_mail(){
        add_filter('option_admin_email', 'mytheme_getwid_change_admin_email');
    }
    
    //Set new recipient address
    function mytheme_getwid_change_admin_email( $value ) {
        return "new-email@mail.com";
    }
    • This reply was modified 3 months ago by aluo.
    Plugin Support Dmytro

    (@dimned)

    Hi @aluo,
    You may add this code to functions.php file of your theme. Do not forget to replace new-email@mail.com with your proper email address in the code.

    aluo

    (@aluo)

    Hi @dimned ,

    Thanks for your response.

    +1 to please integrate this into the GUI form editor.

    Regards,
    Aaron

    Plugin Support Dmytro

    (@dimned)

    Hi @aluo,
    Thanks for your vote. I’ve added it to our list of features. It would help us much if you also rate the plugin here https://wordpress.org/support/plugin/getwid/reviews/

    webdee75

    (@webdee75)

    Hi,
    +1 for adding this feature to Getwid plugin please ! It’s impossible to use a contact form sending messages to the webmaster instead of the site owner, and impossible to give Admin access to a client either…
    Having a different address for the Editor would be great !
    Thanks

    Plugin Support Dmytro

    (@dimned)

    Hi @webdee75,
    Thanks for the feedback.

    webdee75

    (@webdee75)

    I finally used @motopress filter code (above) without child theme, with Code Snippets plugin. It works fine !
    It helps a lot (waiting for the future new feature everybody’s waiting for 😉
    Thanks !

    Plugin Support Dmytro

    (@dimned)

    Hi @webdee75,
    Thanks for your feedback.

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.