function settings_page() { /** * @submit settings page */ if (isset($_POST['submit'])) { $this->upme_update_custom_field($_POST, 'normal'); $this->update(); } /* Create a new field */ if (isset($_POST['upme-add'])) { $this->upme_add_custom_field($_POST, 'normal'); } /* Trash field */ if (strtolower($_SERVER['REQUEST_METHOD']) == 'get') { if (isset($_GET['trash_field']) && !isset($_POST['submit']) && !isset($_POST['reset-options']) && !isset($_POST['reset-options-fields'])) { $fields = get_option('upme_profile_fields'); $trash = $_GET['trash_field']; if (isset($fields[$trash])) { unset($fields[$trash]); update_option('upme_profile_fields', $fields); echo '<div class="updated"><p><strong>' . __('Profile field was sent to Trash.', 'upme') . '</strong></p></div>'; } } } /** * @submit theme reset button */ if (isset($_POST['reset-custom-theme'])) { $this->upme_update_custom_field($_POST, 'normal'); $this->save_default_colors(); $this->update(); } /** * @callback to restore all options */ if (isset($_POST['reset-options'])) { $this->reset(); } if (isset($_POST['reset-options-fields'])) { $this->reset_all('normal'); } ?> <div class="wrap"> <div id="upme-icon upme-icon-<?php echo $this->slug; ?> " class="icon32"> <br /> </div> <h2 class="nav-tab-wrapper"> <?php $this->admin_tabs(); ?> </h2> <form method="post" action="" id="upme-custom-field-add"> <?php $this->get_tab_content(); ?> <p class="submit"> <?php if (upme_get_value('tab') != 'user_cache') { echo UPME_Html::button('submit', array('name' => 'submit', 'id' => 'submit', 'value' => __('Save Changes', 'upme'), 'class' => 'button button-primary')); } ?> <?php if (isset($_GET['tab'])) { $tab = $_GET['tab']; } else { $tab = $this->default_tab; } if ($tab == 'customizer') { echo UPME_Html::button('submit', array('name' => 'reset-options-fields', 'value' => __('Reset to Default Fields', 'upme'), 'class' => 'button button-secondary')); } if ($tab == 'user_cache') { echo UPME_Html::button('button', array('name' => 'reset-options-fields', 'id' => 'upme-update-user-cache', 'value' => __('Update User Cache', 'upme'), 'class' => 'button button-primary')); } ?> </p> </form> </div> <?php }
public function upme_download_export_users() { global $upme_admin; if (upme_is_in_get('current_tab')) { $profileFieldsRaw = get_option('upme_profile_fields'); if (upme_is_in_get('site_export_users_type')) { if (upme_get_value('site_export_users_type') == 'all_users') { $users_query = new WP_User_Query(array('orderby' => 'registered', 'order' => 'desc')); } else { $user = (array) upme_get_value('site_export_users_type'); $users_query = new WP_User_Query(array('orderby' => 'registered', 'order' => 'desc', 'include' => $user)); } $result_users = $users_query->get_results(); } $filename = 'users.csv'; header('Content-Type: application/csv'); header('Content-Disposition: attachement; filename="' . $filename . '";'); $headerArray = array(); $metaArray = array(); foreach ($profileFieldsRaw as $k => $fieldRaw) { if ($fieldRaw['type'] != 'separator' && ($fieldRaw['meta'] != 'user_pass' && $fieldRaw['meta'] != 'user_pass_confirm' && $fieldRaw['meta'] != 'user_pic')) { array_push($headerArray, $fieldRaw['name']); array_push($metaArray, $fieldRaw['meta']); } } $f = fopen('php://output', 'w'); fputcsv($f, $headerArray, ','); //Header foreach ($result_users as $user) { $valuesArr = array(); foreach ($metaArray as $key => $meta) { $value = get_user_meta($user->ID, $meta, true); array_push($valuesArr, $value); } fputcsv($f, $valuesArr, ','); } // exit; } }