Support » Plugin: Contact Form 7 » Member specific information from a custom shortcode in the output

  • Hi,

    I’m trying to get a custom shortcode working on the output of the email so that I can included detailed information about the particular user, most of which can only be accessed with the use of their username/userid/email, I’ve been testing the following code just to output some simple text about the person that used the contact form:

    add_filter( 'wpcf7_special_mail_tags', function ( $output, $name, $html ) {
        $MInfo = 'Details:';
    
        if (!is_user_logged_in()) {
            $MInfo .= "\n" . 'Account: Unregistered/Not Logged In';
        } else {
            $MInfo .= "\n" . 'Account: Registered/Logged In';
        }
        if ($name === 'MInfo'){
            return $MInfo;
        }
    
        return $output;
    
    }, 10, 3 );

    However, regardless of the logged in status it will always output::

    Details:
    Account: Unregistered/Not Logged In

    How can I make the above work… how can I transmit the user ID or email or username to the shortcode?

    Thanks

    • This topic was modified 2 years, 1 month ago by  Hyflex.
  • The topic ‘Member specific information from a custom shortcode in the output’ is closed to new replies.