Namthar Posted June 2, 2022 Share Posted June 2, 2022 Hi ! I will add a custom shortcut in my contactForm7 plugin. I want to email the user. But I have a problem with the email. My shortcut works correctly in the contact form, but it doesn't email the user role The Code add_filter( 'wpcf7_form_elements', 'dacrosby_do_shortcodes_wpcf7_form' ); function dacrosby_do_shortcodes_wpcf7_form( $form ) { $form = do_shortcode( $form ); return $form; } // Allow custom shortcodes in CF7 mailed message body add_filter( 'wpcf7_mail_components', 'dacrosby_do_shortcodes_wpcf7_mail_body', 10, 2 ); function dacrosby_do_shortcodes_wpcf7_mail_body( $components, $number ) { $components['body'] = do_shortcode( $components['body'] ); return $components; }; // Add shortcode normally as per WordPress API add_shortcode('my_code', 'my_code_callback'); function my_code_callback($atts){ $user = wp_get_current_user(); return $user->roles[0]; } It only shows the shortcut in the contact form, but does not send it by email. Can someone help me find the problem? Quote Link to comment https://forums.phpfreaks.com/topic/314882-wordpress-contactfrom7/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.