Working Hours
10.00am - 7.30pm IST (Mon-Fri)
Find Me on
Get a Free Quote
WhatsApp Me
Contact information
Follow us
What is vCard and how to generate vCard from WordPress

This article is about how can we generate vCard from WordPress. Probably, you may have seen a vCard attached to e-mail note which someone has sent you. It is a file format standard for business cards in electronic form.

Checkout this WordPress plugin “Contact Form vCard Generator” if you are looking to generate vCards from contact form inquiries. More information on this plugin available here “How to generate vCards from WordPress Contact Form 7 inquiries

What is vCard?

It is the abbreviation for Virtual Business Card (.vcf file). It was developed by a consortium founded by IBM, Siemens, Apple and AT&T which turned the specification over to an industry group, the Internet Mail Consortium (IMC) in 1996. Furthermore the specification makes use of the “person” object defined by the CCITT X.500 Series Recommendation for Directory Services and can be considered an extension of it.

Because vCards are published with industry specification and it is a standard, there are many applications available that process it. Therefore these applications letting you view them, or drag-and-drop them to an address book or some other application.

What information it can contain

  • Name
  • Address
  • Phone numbers
  • Email addresses
  • URLs
  • Logos and Images
  • Audio clips
  • etc…

View or generate vCard

To view a vCard that someone has send you as attachment to an e-mail, your e-mail application/program needs to support it. Because not all such programs do yet. However, if you have an online address book or personal information manager that supports vCards, you can move it to that program for viewing. Today almost all email application/clients are supporing vCards.

How to generate for contact information:

  • Click on Address Book
  • Find and Click on the contact you want to send
  • From the Contact menu, click “Forward as vCard”
  • Enter the name of the person to whom you want to send the contact information and complete the message
  • Click on Send Now

How to add to address book:

  • Open up the message having the vCard
  • Click on Address Book
  • Drag the vCard to the Address Book list, the information will be automatically filled with vCard

Available versions of vCard and examples

More on format specification: https://tools.ietf.org/html/rfc6350

1. Version 2.1

BEGIN:VCARD
VERSION:2.1
N:Gump;Forrest
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;GIF:http://www.example.com/dir_photos/my_photo.gif
TEL;WORK;VOICE:(111) 555-1212
TEL;HOME;VOICE:(404) 555-1212
ADR;WORK:;;100 Waters Edge;Baytown;
LA;30314;United States of America
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:100 Waters Edge=0D=0ABaytown,
LA 30314=0D=0AUnited States of America
ADR;HOME:;;42 Plantation St.;Baytown;
LA;30314;United States of America
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:42 Plantation St.=0D=0ABaytown,
LA 30314=0D=0AUnited States of America
EMAIL;PREF;INTERNET:forrestgump@example.com
REV:20080424T195243Z
END:VCARD

2. Version 3.0

BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest;;Mr.
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;VALUE=URL;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif
TEL;TYPE=WORK,VOICE:(111) 555-1212
TEL;TYPE=HOME,VOICE:(404) 555-1212
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;
LA;30314;United States of America
LABEL;TYPE=WORK:100 Waters Edge\nBaytown\,
LA 30314\nUnited States of America
ADR;TYPE=HOME:;;42 Plantation St.;Baytown;
LA;30314;United States of America
LABEL;TYPE=HOME:42 Plantation St.\nBaytown\,
LA 30314\nUnited States of America
EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com
REV:2008-04-24T19:52:43Z
END:VCARD

3. Version 4.0

BEGIN:VCARD
VERSION:4.0
N:Gump;Forrest;;;
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212
ADR;TYPE=work;LABEL="100 Waters Edge\nBaytown,
LA 30314\nUnited States of America":;;100 Waters Edge;Baytown;
LA;30314;United States of America
ADR;TYPE=home;LABEL="42 Plantation St.\nBaytown,
LA 30314\nUnited States of
America":;;42 Plantation St.;Baytown;
LA;30314;United States of America
EMAIL:forrestgump@example.com
REV:20080424T195243Z
END:VCARD

Sample code on how to generate vCard from WordPress post

require_once('class_vcard.php');
require_once ('wp-load.php');

$vpost = get_post($_REQUEST['pid']);
$featured_image = wp_get_attachment_url(get_post_thumbnail_id($vpost->ID));

/* Instantiate a new vcard object. */
$vc = new vcard();
$vc->class = "PUBLIC";

/* Fill in data for vCard */
$vc->filename = strtolower(str_replace(" ","-",$vpost->post_title));
$vc->data['first_name'] = $vpost->post_title;
$vc->data['company'] = get_field('company_name',$vpost->ID);
$vc->data['department'] = get_field('department',$vpost->ID);
$vc->data['title'] = get_field('expertise',$vpost->ID);
$vc->data['office_tel'] = get_field('phone',$vpost->ID);
$vc->data['email1'] = get_field('email_address',$vpost->ID);
$vc->data['url'] = get_field('linkedin_profile_url',$vpost->ID);
$vc->data['photo'] = $featured_image;
$vc->data['note'] = strip_tags($vpost->post_content);

/* Generate vcard and send as a .vcf file to user's browser for download.*/
$vc->download();

Finally, Click here to download complete source code.  If you find any difficulties then please feel free to connect with me and I will help in the process to generate vCard from WordPress.

(2)
  • RobinFebruary 18, 2018

    Hello Ashish,
    Thank you for posting your code – would you be kind enough to publish a “how-to” document in order to let readers know how to install your scripts on a WP installation? I believe that would be of real help to many.

    In addition, we are thousands using Contact-form-7 and it lacks the “save vcf” functionality. So perhaps you could develop this…

    All the best,
    Robin

  • Ajani AshishJuly 9, 2018

    Hi Robin, thank you for sharing your feedback. Really appreciated.

    I’ve prepared and hosted one WordPress plugin at the official WordPress site. You can download plugin from here:
    https://wordpress.org/plugins/contact-form-vcard-generator/

    This plugin will allow generating vCard for a single form submission or you can download one vcf file containing information for all contact inquiries. It also provides facility to map different contact form 7 fields with vCard information.

    Here is more details on how to use this plugin and it’s features:
    https://freelancer-coder.com/wordpress-contact-form-vcard-generator/

Leave a Reply

Your email address will not be published. Required fields are marked *

Transform your vision into reality!
Let's start building your dream website now.
Get a Free Quote