Guest User

Untitled

a guest
Apr 27th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. <?php
  2.  
  3. function makeVcard2( $id ) {
  4. if( function_exists( 'get_users' ) ) {
  5. global $wpdb;
  6.  
  7. // Arguments for get_users
  8. $args = array(
  9. 'blog_id' => $GLOBALS['blog_id'],
  10. 'fields' => 'all'
  11. );
  12.  
  13. // Query users with args
  14. $blogusers = get_users( $args );
  15.  
  16. // Loop
  17. if( $blogusers ) {
  18. foreach ( $blogusers as $user ) {
  19. // Get userdata
  20. if( function_exists( 'get_userdata' ) )
  21. $userdata[] = get_userdata( $user->ID );
  22. }
  23. }
  24.  
  25. var_dump( $userdata );
  26. if( $userdata ) {
  27. $v_type = 'company';
  28. $v_first = $userdata->first_name;
  29. $v_last = $userdata->last_name;
  30. $v_company = get_bloginfo( 'name' ) . " " . get_bloginfo( 'description' );
  31. $v_title = $userdata->tagline;
  32. $v_email = $userdata->user_email;
  33. $v_web = get_bloginfo('url');
  34. $v_street = $userdata->address;
  35. $v_city = $userdata->city;
  36. $v_state = $userdata->state;
  37. $v_zip = $userdata->postalcode;
  38. $v_country = 'USA';
  39. $v_phone = $userdata->phone;
  40. $v_fax = $userdata->fax;
  41. }
  42.  
  43. $v_middle = 'Joseph';
  44. $v_nick = 'Tommy Salami';
  45. $v_note = 'This is a note';
  46.  
  47. $vt = ( $v_type == 'company' ) ? 'WORK' : 'HOME';
  48. $fn = ( $v_type == 'company' ) ? 'FN:' . $v_company . '\r' : 'FN:' . $v_first . ' ' . $v_middle . ' ' . $v_last . '\r';
  49.  
  50. $vcard_content = 'BEGIN:VCARD\r';
  51. $vcard_content .= 'VERSION:3.0\r';
  52. $vcard_content .= 'N:'.$v_last.';'.$v_first.';'.$v_middle.';;\r';
  53. $vcard_content .= $fn;
  54. $vcard_content .= 'NICKNAME:'.$v_nick.'\r';
  55. $vcard_content .= 'ORG:'.$v_company.';\r';
  56. $vcard_content .= 'TITLE:'.$v_title.'\r';
  57. $vcard_content .= 'EMAIL;type=INTERNET;type='.$vt.';type=pref:'.$v_email.'\r';
  58. $vcard_content .= 'TEL;type='.$vt.';type=pref:'.$v_phone.'\r';
  59. $vcard_content .= 'TEL;type=CELL:'.$v_cell.'\r';
  60. $vcard_content .= 'TEL;type='.$vt.';type=FAX:'.$v_fax.'\r';
  61. $vcard_content .= 'item1.ADR;type='.$vt.';type=pref:;;'.$v_street.';'.$v_city.';'.$v_state.';'.$v_zip.';'.$v_country.'\r';
  62. $vcard_content .= 'item1.X-ABADR:us\r';
  63. $vcard_content .= 'item2.URL;type=pref:'.$v_web.'\r';
  64. $vcard_content .= 'item2.X-ABLabel:_$!<HomePage>!\$\_\r';
  65. $vcard_content .= 'NOTE:'.$v_note.'\r';
  66.  
  67. if ($v_type=='company') { $vcard_content .= 'X-ABShowAs:COMPANY\r'; }
  68.  
  69. $vcard_content .= 'END:VCARD';
  70.  
  71. return $vcard_content;
  72.  
  73. }
  74.  
  75.  
  76. ?>
Add Comment
Please, Sign In to add comment