• Resolved one3rdnerd

    (@one3rdnerd)


    Hello,

    I was wondering if there is a way to control the admin email for a contact form in the back end using custom meta field.

    Example…

    I have micro sites and I want to populate the admin email from an ACF options page.

    I can create these fields and have them output on the front end.

    Is it possible to add this into the WPForms form settings for notifications?

    It would be cool if one of the smart tags allowed you to reference a custom field.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter one3rdnerd

    (@one3rdnerd)

    I found what I think is the solution but so far haven’t been able to get it to grab the email address from an ACF options field with the below:

    /**
     * Register the Smart Tag so it will be available to select in the form builder.
     *
     * @link   https://wpforms.com/developers/how-to-create-a-custom-smart-tag/
     *
     */
    function wpf_dev_register_smarttag( $tags ) {
     
        // Key is the tag, item is the tag name.
        $tags['xorganisers_email'] = 'Organisers Email';
     
        return $tags;
    }
    add_filter( 'wpforms_smart_tags', 'wpf_dev_register_smarttag' );
     
    /**
     * Process the Smart Tag.
     *
     *   https://wpforms.com/developers/how-to-create-a-custom-smart-tag/
     *
     */
    
    function wpf_dev_process_smarttag( $content, $tag ) {
     
        // Only run if it is our desired tag.
        if ( 'xorganisers_email' === $tag ) {
    		$theemailx = get_field('organisers_email', 'option');
    		
            // Replace the tag with our link.
            $content = str_replace( '{xorganisers_email}', $theemailx, $content );
        }
     
        return $content;
    }
    add_filter( 'wpforms_smart_tag_process', 'wpf_dev_process_smarttag', 10, 2 );

    The above option appears in WPForms as a smart tag but it’s not grabbing the email address from the field.

    Any ideas what I could be doing wrong?

    • This reply was modified 3 years, 9 months ago by one3rdnerd.
    Thread Starter one3rdnerd

    (@one3rdnerd)

    I solved it. I must have changed my field name.

    The above works for anyone else who wants to do this.

    Just change your field name from organisers_email to whatever you create in ACF.

    Plugin Support Ethan Choi

    (@ethanchoi)

    Hi @one3rdnerd,

    We’re glad to hear you’ve got that sorted and thanks for the update! If you’d like more help with using WPForms Lite, please feel free to reach out.

    Thanks ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Use an ACF Field for the Form Admin Email?’ is closed to new replies.