function userpro_admin_woo_sync()
{
    $fields = get_option('userpro_fields');
    $builtin = get_option('userpro_fields_builtin');
    $woo_billing['billing_first_name'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing First Name');
    $woo_billing['billing_last_name'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing Last Name');
    $woo_billing['billing_company'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing Company');
    $woo_billing['billing_address_1'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing Address 1');
    $woo_billing['billing_address_2'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing Address 2');
    $woo_billing['billing_city'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing City');
    $woo_billing['billing_postcode'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing Postcode');
    $woo_billing['billing_country'] = array('woo' => 1, 'type' => 'select', 'label' => 'Billing Country', 'options' => userpro_filter_to_array('country'), 'placeholder' => 'Select your Country');
    $woo_billing['billing_state'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing State');
    $woo_billing['billing_email'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing E-mail');
    $woo_billing['billing_phone'] = array('woo' => 1, 'type' => 'text', 'label' => 'Billing Phone');
    $woo_shipping['shipping_first_name'] = array('woo' => 1, 'type' => 'text', 'label' => 'Shipping First Name');
    $woo_shipping['shipping_last_name'] = array('woo' => 1, 'type' => 'text', 'label' => 'Shipping Last Name');
    $woo_shipping['shipping_company'] = array('woo' => 1, 'type' => 'text', 'label' => 'Shipping Company');
    $woo_shipping['shipping_address_1'] = array('woo' => 1, 'type' => 'text', 'label' => 'Shipping Address 1');
    $woo_shipping['shipping_address_2'] = array('woo' => 1, 'type' => 'text', 'label' => 'Shipping Address 2');
    $woo_shipping['shipping_city'] = array('woo' => 1, 'type' => 'text', 'label' => 'Shipping City');
    $woo_shipping['shipping_postcode'] = array('woo' => 1, 'type' => 'text', 'label' => 'Shipping Postcode');
    $woo_shipping['shipping_country'] = array('woo' => 1, 'type' => 'select', 'label' => 'Shipping Country', 'options' => userpro_filter_to_array('country'), 'placeholder' => 'Select your Country');
    $woo_shipping['shipping_state'] = array('woo' => 1, 'type' => 'text', 'label' => 'Shipping State');
    $woo = $woo_billing + $woo_shipping;
    $all_fields = $woo + $fields;
    $all_builtin = $woo + $builtin;
    update_option('userpro_fields_woo', $woo);
    update_option('userpro_fields', $all_fields);
    update_option('userpro_fields_builtin', $all_builtin);
    update_option("userpro_update_woosync", 1);
}
Esempio n. 2
0
function userpro_init_setup()
{
    global $userpro;
    if (!empty($userpro->fields) && !get_option('userpro_pre_icons_setup')) {
        $userpro->update_field_icons();
    }
    if (!get_option('userpro_pre_icons_setup')) {
        $userpro->update_field_icons();
    }
    /* Setup Fields */
    if (!get_option('userpro_fields')) {
        $userpro_fields['first_name'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'First Name');
        $userpro_fields['last_name'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'Last Name');
        $userpro_fields['display_name'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'Profile Display Name', 'help' => 'Your profile name/nickname that is displayed to public.');
        $userpro_fields['user_login'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'Username');
        $userpro_fields['user_email'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'E-mail Address');
        $userpro_fields['username_or_email'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'Username or E-mail');
        $userpro_fields['user_pass'] = array('_builtin' => 1, 'type' => 'password', 'label' => 'Password', 'help' => 'Your password must be 8 characters long at least.');
        $userpro_fields['user_pass_confirm'] = array('_builtin' => 1, 'type' => 'password', 'label' => 'Confirm your Password');
        $userpro_fields['passwordstrength'] = array('_builtin' => 1, 'type' => 'passwordstrength', 'label' => 'Password Strength Meter', 'too_short' => 'Password too short', 'very_strong' => 'Very Strong', 'strong' => 'Strong', 'good' => 'Good', 'weak' => 'Weak', 'very_weak' => 'Very Weak');
        $userpro_fields['country'] = array('_builtin' => 1, 'type' => 'select', 'label' => 'Country/Region', 'options' => userpro_filter_to_array('country'), 'placeholder' => 'Select your Country');
        $userpro_fields['role'] = array('_builtin' => 1, 'type' => 'select', 'label' => 'Role', 'options' => userpro_filter_to_array('roles'), 'placeholder' => 'Select your account type');
        $userpro_fields['profilepicture'] = array('_builtin' => 1, 'type' => 'picture', 'label' => 'Profile Picture', 'button_text' => 'Upload a profile picture', 'help' => 'Upload a picture that presents you across the site.');
        $userpro_fields['gender'] = array('_builtin' => 1, 'type' => 'radio', 'label' => 'Gender', 'options' => array('male' => 'Male', 'female' => 'Female'));
        $userpro_fields['description'] = array('_builtin' => 1, 'type' => 'textarea', 'label' => 'Biography', 'help' => 'Describe yourself.', 'html' => 1);
        $userpro_fields['facebook'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'Facebook Page');
        $userpro_fields['twitter'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'Twitter');
        $userpro_fields['google_plus'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'Google+');
        $userpro_fields['user_url'] = array('_builtin' => 1, 'type' => 'text', 'label' => 'Website (URL)');
        /**
         * Security Question Answer new Filed Start
         * By Rahul
         * On 21 NOV 2014
         */
        $userpro_fields['securityqa'] = array('_builtin' => 1, 'type' => 'securityqa', 'label' => 'Are You A Human?');
        /**
         * Security Question Answer new Filed End
         * By Rahul
         * On 21 NOV 2014
         */
        update_option('userpro_fields', $userpro_fields);
        update_option('userpro_fields_builtin', $userpro_fields);
    }
    /* Setup Field Groups */
    if (!get_option('userpro_fields_groups')) {
        $userpro_fields_groups['register']['default'] = array('accountinfo' => userpro_add_section(__('Account Details', 'userpro'), 1, 0), 'user_login' => userpro_add_field('user_login', 0, 0, 1, 'username_exists'), 'user_email' => userpro_add_field('user_email', 1, 0, 1, 'email_exists'), 'user_pass' => userpro_add_field('user_pass', 0, 0, 1, null), 'user_pass_confirm' => userpro_add_field('user_pass_confirm', 0, 0, 0, null), 'passwordstrength' => userpro_add_field('passwordstrength', 0, 0, 0, null), 'profile' => userpro_add_section(__('Profile Details', 'userpro'), 1, 1), 'display_name' => userpro_add_field('display_name', 0, 0, 0, null), 'profilepicture' => userpro_add_field('profilepicture', 0, 0, 0, null), 'gender' => userpro_add_field('gender', 0, 0, 0, null), 'country' => userpro_add_field('country', 0, 0, 0, null), 'social' => userpro_add_section(__('Social Profiles', 'userpro'), 1, 1), 'facebook' => userpro_add_field('facebook', 0, 0, 0, null), 'twitter' => userpro_add_field('twitter', 0, 0, 0, null), 'google_plus' => userpro_add_field('google_plus', 0, 0, 0, null), 'user_url' => userpro_add_field('user_url', 0, 0, 0, null));
        $userpro_fields_groups['login']['default'] = array('username_or_email' => userpro_add_field('username_or_email', 0, 0, 1, null), 'user_pass' => userpro_add_field('user_pass', 0, 0, 1, null));
        $userpro_fields_groups['edit']['default'] = array('profile' => userpro_add_section(__('Profile Details', 'userpro'), 1, 0), 'display_name' => userpro_add_field('display_name', 0, 0, 0, null), 'profilepicture' => userpro_add_field('profilepicture', 0, 0, 0, null), 'first_name' => userpro_add_field('first_name', 0, 0, 0, null), 'last_name' => userpro_add_field('last_name', 0, 0, 0, null), 'description' => userpro_add_field('description', 0, 0, 0, null), 'gender' => userpro_add_field('gender', 0, 0, 0, null), 'country' => userpro_add_field('country', 0, 0, 0, null), 'social' => userpro_add_section(__('Social Profiles', 'userpro'), 1, 0), 'facebook' => userpro_add_field('facebook', 0, 0, 0, null), 'twitter' => userpro_add_field('twitter', 0, 0, 0, null), 'google_plus' => userpro_add_field('google_plus', 0, 0, 0, null), 'user_url' => userpro_add_field('user_url', 0, 0, 0, null), 'accountinfo' => userpro_add_section(__('Account Details', 'userpro'), 1, 0), 'user_email' => userpro_add_field('user_email', 1, 0, 0, null), 'user_pass' => userpro_add_field('user_pass', 0, 0, 0, null), 'user_pass_confirm' => userpro_add_field('user_pass_confirm', 0, 0, 0, null), 'passwordstrength' => userpro_add_field('passwordstrength', 0, 0, 0, null));
        $userpro_fields_groups['view']['default'] = $userpro_fields_groups['edit']['default'];
        $userpro_fields_groups['social']['default'] = array('user_email' => userpro_add_field('user_email'), 'facebook' => userpro_add_field('facebook'), 'twitter' => userpro_add_field('twitter'), 'google_plus' => userpro_add_field('google_plus'), 'user_url' => userpro_add_field('user_url'));
        update_option('userpro_fields_groups', $userpro_fields_groups);
        update_option('userpro_fields_groups_default', $userpro_fields_groups);
        update_option('userpro_fields_groups_default_register', $userpro_fields_groups['register']['default']);
        update_option('userpro_fields_groups_default_login', $userpro_fields_groups['login']['default']);
        update_option('userpro_fields_groups_default_edit', $userpro_fields_groups['edit']['default']);
        update_option('userpro_fields_groups_default_view', $userpro_fields_groups['edit']['default']);
        update_option('userpro_fields_groups_default_social', $userpro_fields_groups['social']['default']);
    }
}
function userpro_create_field()
{
    if (!current_user_can('manage_options')) {
        die;
    }
    // admin priv
    extract($_POST);
    $newfield = array();
    if (empty($upadmin_n_title)) {
        $output['error']['upadmin_n_title'] = __('Each field must have a title.', 'userpro');
    } elseif (empty($upadmin_n_key) && empty($upadmin_n_sync)) {
        $output['error']['upadmin_n_key'] = __('Please enter a unique key or choose an existing usermeta.', 'userpro');
    } else {
        if (isset($upadmin_n_sync) && !empty($upadmin_n_sync)) {
            $key = $upadmin_n_sync;
        } else {
            $key = $upadmin_n_key;
        }
        // check that field key is unique
        $fields = get_option('userpro_fields');
        if (isset($fields[$upadmin_n_sync]) && !empty($upadmin_n_sync)) {
            $output['error']['upadmin_n_sync'] = __('This existing usermeta already exists in your fields list below.', 'userpro');
        } elseif (isset($fields[$upadmin_n_key]) && !empty($upadmin_n_key)) {
            $output['error']['upadmin_n_key'] = __('This unique key already exists in your fields list below.', 'userpro');
        } else {
            // create the field
            $newfield[$key] = array('_builtin' => 0, 'type' => $upadmin_n_type);
            if (isset($upadmin_n_title) && !empty($upadmin_n_title)) {
                $newfield[$key]['label'] = $upadmin_n_title;
            }
            if (isset($upadmin_n_help) && !empty($upadmin_n_help)) {
                $newfield[$key]['help'] = $upadmin_n_help;
            }
            if (isset($upadmin_n_ph) && !empty($upadmin_n_ph)) {
                $newfield[$key]['placeholder'] = $upadmin_n_ph;
            }
            if (isset($upadmin_n_filetypes) && !empty($upadmin_n_filetypes)) {
                $newfield[$key]['allowed_extensions'] = str_replace(' ', '', $upadmin_n_filetypes);
            } elseif ($upadmin_n_type == 'file') {
                $newfield[$key]['allowed_extensions'] = 'zip,pdf,txt';
            }
            if (isset($upadmin_n_choices_builtin) && !empty($upadmin_n_choices_builtin)) {
                $newfield[$key]['options'] = userpro_filter_to_array($upadmin_n_choices_builtin);
            } elseif (isset($upadmin_n_choices) && !empty($upadmin_n_choices)) {
                $n_choices = preg_split('/[\\r\\n]+/', $upadmin_n_choices, -1, PREG_SPLIT_NO_EMPTY);
                $newfield[$key]['options'] = $n_choices;
            }
            /* finished creating new field */
            $allfields = $newfield + $fields;
            update_option('userpro_fields', $allfields);
            $output['html'] = userpro_admin_list_fields($key);
            $output['count'] = userpro_admin_count_fields();
        }
    }
    $output = json_encode($output);
    if (is_array($output)) {
        print_r($output);
    } else {
        echo $output;
    }
    die;
}