<?php define('TT_CUSTOM_USERMETA_FOLDER_PATH', TT_MODULES_FOLDER_PATH . 'registration/custom_usermeta/'); define('TT_REGISTRATION_FOLDER_PATH', TT_MODULES_FOLDER_PATH . 'registration/'); include_once TT_CUSTOM_USERMETA_FOLDER_PATH . 'db_custom_usermeta.php'; include_once TT_REGISTRATION_FOLDER_PATH . 'registration_main.php'; $form_fields_usermeta_usermeta = array(); $form_fields_usermeta['user_email'] = array("label" => 'E-mail', "type" => 'text', "default" => '', "extra" => 'id="user_email" size="25" class="textfield"', "is_require" => '1', "outer_st" => '<div class="form_row clearfix">', "outer_end" => '</div>', "tag_st" => '', "tag_end" => '', "on_registration" => '1', "on_profile" => '1'); $form_fields_usermeta['user_fname'] = array("label" => 'Full Name', "type" => 'text', "default" => '', "extra" => 'id="user_fname" size="25" class="textfield"', "is_require" => '1', "outer_st" => '<div class="form_row clearfix">', "outer_end" => '</div>', "tag_st" => '', "tag_end" => '', "on_registration" => '1', "on_profile" => '1'); $custom_metaboxes = templ_get_usermeta(); foreach ($custom_metaboxes as $key => $val) { $name = $val['name']; $site_title = $val['site_title']; $type = $val['type']; $default_value = $val['default']; $is_require = $val['is_require']; $admin_desc = $val['desc']; $option_values = $val['option_values']; $on_registration = $val['on_registration']; $on_profile = $val['on_profile']; if ($type == 'text') { $form_fields_usermeta[$name] = array("label" => $site_title, "type" => 'text', "default" => $default_value, "extra" => 'id="' . $name . '" size="25" class="textfield"', "is_require" => $is_require, "outer_st" => '<div class="form_row clearfix">', "outer_end" => '</div>', "tag_st" => '', "tag_end" => '<span class="message_note">' . $admin_desc . '</span>', "on_registration" => $on_registration, "on_profile" => $on_profile); } elseif ($type == 'checkbox') { $form_fields_usermeta[$name] = array("label" => $site_title, "type" => 'checkbox', "default" => $default_value, "extra" => 'id="' . $name . '" size="25" class="checkbox"', "is_require" => $is_require, "outer_st" => '<div class="form_row clearfix checkbox_field">', "outer_end" => '', "tag_st" => '', "tag_end" => '<span class="message_note">' . $admin_desc . '</span></div>', "on_registration" => $on_registration, "on_profile" => $on_profile); } elseif ($type == 'textarea') { $form_fields_usermeta[$name] = array("label" => $site_title, "type" => 'textarea', "default" => $default_value, "extra" => 'id="' . $name . '" size="25" class="textarea"', "is_require" => $is_require, "outer_st" => '<div class="form_row clearfix">', "outer_end" => '</div>', "tag_st" => '', "tag_end" => '<span class="message_note">' . $admin_desc . '</span>', "on_registration" => $on_registration, "on_profile" => $on_profile); } elseif ($type == 'texteditor') { $form_fields_usermeta[$name] = array("label" => $site_title, "type" => 'texteditor', "default" => $default_value, "extra" => 'id="' . $name . '" size="25" class="textarea mceEditor"', "is_require" => $is_require, "outer_st" => '<div class="form_row clear">', "outer_end" => '</div>', "tag_before" => '<div class="clear">', "tag_after" => '</div>', "tag_st" => '', "tag_end" => '<span class="message_note">' . $admin_desc . '</span>', "on_registration" => $on_registration, "on_profile" => $on_profile); } elseif ($type == 'select') { //$option_values=explode(",",$option_values ); $form_fields_usermeta[$name] = array("label" => $site_title, "type" => 'select', "default" => $default_value, "extra" => 'id="' . $name . '" class="select xl"', "options" => $option_values, "is_require" => $is_require, "outer_st" => '<div class="form_row clear">', "outer_end" => '</div>', "tag_st" => '', "tag_end" => '', "on_registration" => $on_registration, "on_profile" => $on_profile);
function save_extra_user_profile_fields($user_id) { global $wpdb; if (!current_user_can('edit_user', $user_id)) { return false; } $user_facebook = $_POST['user_facebook']; $user_twitter = $_POST['user_twitter']; update_usermeta($user_id, 'user_facebook', $user_facebook); update_usermeta($user_id, 'user_twitter', $user_twitter); global $upload_folder_path; $custom_metaboxes = templ_get_usermeta('profile'); foreach ($custom_metaboxes as $fkey => $fval) { $fldkey = "{$fkey}"; ${$fldkey} = $_POST["{$fkey}"]; if ($fval['type'] == 'upload') { if ($_FILES[$fkey]['name'] && $_FILES[$fkey]['size'] > 0) { $dirinfo = wp_upload_dir(); $path = $dirinfo['path']; $url = $dirinfo['url']; $destination_path = $path . "/"; $destination_url = $url . "/"; $src = $_FILES[$fkey]['tmp_name']; $file_ame = date('Ymdhis') . "_" . $_FILES[$fkey]['name']; $target_file = $destination_path . $file_ame; if (move_uploaded_file($_FILES[$fkey]["tmp_name"], $target_file)) { $image_path = $destination_url . $file_ame; } else { $image_path = ''; } $_POST[$fkey] = $image_path; $fldkey = $image_path; } else { $_POST[$fkey] = $_POST['prev_upload']; } } update_usermeta($user_id, $fkey, ${$fldkey}); // User Custom Metadata Here } }