Advertisement
Guest User

Untitled

a guest
May 31st, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.08 KB | None | 0 0
  1. add_action( 'show_user_profile', 'display_user_detail_user_meta' );
  2. add_action( 'edit_user_profile', 'display_user_detail_user_meta' );
  3.  
  4. function display_user_detail_user_meta ( $user ) { ?>
  5.  
  6. <h3>سایر اطلاعات کاربر</h3>
  7. <table class="form-table">
  8. <tr>
  9. <th><label>کد ملی</label></th>
  10. <td><input id="unatinalcode" type="text" value="<?php echo get_user_meta( $user->ID, 'unatinalcode', true ); ?>" class="regular-text" /> </td>
  11. </tr>
  12. <tr>
  13. <th><label>استان</label></th>
  14. <td><input name="uostan" type="text" value="<?php echo get_user_meta( $user->ID, 'uostan', true ); ?>" class="regular-text" /></td>
  15. </tr>
  16. <tr>
  17. <th><label>شهر</label></th>
  18. <td><input name="ucity" type="text" value="<?php echo get_user_meta( $user->ID, 'ucity', true ); ?>" class="regular-text" /></td>
  19. </tr>
  20. <tr>
  21. <th><label>آدرس</label></th>
  22. <td><input id="uaddress" type="text" value="<?php echo get_user_meta( $user->ID, 'uaddress', true ); ?>" class="regular-text" /></td>
  23. </tr>
  24. <tr>
  25. <th><label>شماره تماس</label></th>
  26. <td><input id="umobile" type="text" value="<?php echo get_user_meta( $user->ID, 'umobile', true ); ?>" class="regular-text" /></td>
  27. </tr>
  28. <tr>
  29. <th><label>شماره موبایل</label></th>
  30. <td><input id="utel" type="text" value="<?php echo get_user_meta( $user->ID, 'utel', true ); ?>" class="regular-text" /></td>
  31. </tr>
  32. <tr>
  33. <th><label>نام مدیر</label></th>
  34. <td><input id="umanagername" type="text" value="<?php echo get_user_meta( $user->ID, 'umanagername', true ); ?>" class="regular-text" /> </td>
  35. </tr>
  36. <tr>
  37. <th><label>شماره مدیر</label></th>
  38. <td><input id="umanagertel" type="text" value="<?php echo get_user_meta( $user->ID, 'umanagertel', true ); ?>" class="regular-text" /></td>
  39. </tr>
  40. </table>
  41. <h3>اطلاعات فروشنده</h3>
  42. <table style="width: 100px;" class="form-table">
  43. <tr>
  44. <th style="width: 10%;"><label>ردیف</label></th>
  45. <th style="width: 45%; text-align: right"><label>نام فروشنده</label></th>
  46. <th style="width: 45%;"><label>شماره تماس فروشنده</label></th>
  47. </tr>
  48. <tr>
  49. <th style="width: 10%;"><label>یک</label></th>
  50. <td style="width: 45%; text-align: right"><input id="uname1" type="text" value="<?php echo get_user_meta( $user->ID, 'uname1', true ); ?>" class="regular-text" /></td>
  51. <td style="width: 45%; text-align: right"><input id="utel1" type="text" value="<?php echo get_user_meta( $user->ID, 'utel1', true ); ?>" class="regular-text" /></td>
  52. </tr>
  53. <tr>
  54. <th style="width: 10%;"><label>دو</label></th>
  55. <td style="width: 45%; text-align: right"><input id="uname2" type="text" value="<?php echo get_user_meta( $user->ID, 'uname2', true ); ?>" class="regular-text" /></td>
  56. <td style="width: 45%; text-align: right"><input id="utel2" type="text" value="<?php echo get_user_meta( $user->ID, 'utel2', true ); ?>" class="regular-text" /></td>
  57. </tr>
  58. <tr>
  59. <th style="width: 10%;"><label>سه</label></th>
  60. <td style="width: 45%; text-align: right"><input id="uname3" type="text" value="<?php echo get_user_meta( $user->ID, 'uname3', true ); ?>" class="regular-text" /></td>
  61. <td style="width: 45%; text-align: right"><input id="utel3" type="text" value="<?php echo get_user_meta( $user->ID, 'utel3', true ); ?>" class="regular-text" /></td>
  62. </tr>
  63. <tr>
  64. <th style="width: 10%;"><label>چهار</label></th>
  65. <td style="width: 45%; text-align: right"><input id="uname4" type="text" value="<?php echo get_user_meta( $user->ID, 'uname4', true ); ?>" class="regular-text" /></td>
  66. <td style="width: 45%; text-align: right"><input id="utel4" type="text" value="<?php echo get_user_meta( $user->ID, 'utel4', true ); ?>" class="regular-text" /></td>
  67. </tr>
  68. <tr>
  69. <th style="width: 10%;"><label>پنج</label></th>
  70. <td style="width: 45%; text-align: right"><input id="uname5" type="text" value="<?php echo get_user_meta( $user->ID, 'uname5', true ); ?>" class="regular-text" /></td>
  71. <td style="width: 45%; text-align: right"><input id="utel5" type="text" value="<?php echo get_user_meta( $user->ID, 'utel5', true ); ?>" class="regular-text" /></td>
  72. </tr>
  73. </table>
  74. <?php
  75. // Update if editor is current user
  76. add_action( 'personal_options_update', 'update_extra_profile_fields' );
  77. // Update if editor is not current user
  78. add_action( 'edit_user_profile_update', 'update_extra_profile_fields' );
  79.  
  80. function update_extra_profile_fields() {
  81. $user = wp_get_current_user();
  82. $userid = $user->ID;
  83. if ( current_user_can( 'edit_user', $user_id ) )
  84. update_user_meta( $user_id, 'ucity', $_POST['ucity'] );
  85. update_user_meta( $user_id, 'uostan', $_POST['uostan'] );
  86. echo $_POST['ucity'];
  87. echo $_POST['uostan'];
  88. }
  89.  
  90. }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement