What is vCard and how to generate vCard from WordPress

What is vCard and how to generate vCard from WordPress

Posted on 13 Aug, 2015 by Ajani Ashish | 1 comment

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.

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

FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
TEL;WORK;VOICE:(111) 555-1212
TEL;HOME;VOICE:(404) 555-1212
ADR;WORK:;;100 Waters Edge;Baytown;
     LA;30314;United States of America
     LA 30314=0D=0AUnited States of America
ADR;HOME:;;42 Plantation St.;Baytown;
     LA;30314;United States of America
     LA 30314=0D=0AUnited States of America

2. Version 3.0

FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
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

3. Version 4.0

FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
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

Sample code on how to generate vCard from WordPress post

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.

Related Post

With WP Church Donation WordPress plugin, church websites built with WordPress can accept donations from sponsors, donors, members, fans and supporters via Authorize.net credit card payment options. If you are having...

Read More

How to hide WordPress admin bar

Posted on 29 Jul, 2015 by Ajani Ashish | No comment I 3049 views

WordPress admin bar is a toolbar shown at the top. When we already logged in at WordPress backend and browse the frontend then it will appear at the top. This tool bar provides various helpful options which allow us...

Read More
Comment (1)
| 18 February 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,

Speak Your Mind

× 2 = twelve