function simplr_admin_actions()
{
    if (isset($_GET['page']) and $_GET['page'] == 'simplr_reg_set') {
        $data = $_POST;
        $simplr_reg = get_option('simplr_reg_options');
        //
        if (isset($data['recaptcha-submit'])) {
            if (!wp_verify_nonce(-1, $data['reg-api']) && !current_user_can('manage_options')) {
                wp_die('Death to hackers!');
            }
            $simplr_reg->recap_public = $data['recap_public'];
            $simplr_reg->recap_private = $data['recap_private'];
            $simplr_reg->recap_on = $data['recap_on'];
            update_option('simplr_reg_options', $simplr_reg);
        } elseif (isset($data['fb-submit'])) {
            if (!wp_verify_nonce(-1, @$data['reg-fb']) && !current_user_can('manage_options')) {
                wp_die('Death to hackers!');
            }
            $simplr_reg->fb_connect_on = $data['fb_connect_on'];
            $simplr_reg->fb_app_id = @$data['fb_app_id'];
            $simplr_reg->fb_app_key = @$data['fb_app_key'];
            $simplr_reg->fb_app_secret = @$data['fb_app_secret'];
            $simplr_reg->fb_login_allow = @$data['fb_login_allow'];
            $simplr_reg->fb_login_redirect = @$data['fb_login_redirect'];
            $simplr_reg->fb_request_perms = @$data['fb_request_perms'];
            $simplr_reg->fb_auto_register = @$data['fb_auto_register'];
            update_option('simplr_reg_options', $simplr_reg);
            simplr_set_message('updated notice is-dismissible', __("Your settings were saved.", 'simplr-registration-form'));
            wp_redirect($_SERVER['REQUEST_URI']);
        }
        if (isset($data['main-submit'])) {
            //security check
            if (!wp_verify_nonce(-1, $data['reg-main']) && !current_user_can('manage_options')) {
                wp_die('Death to hackers!');
            }
            $simplr_reg->email_message = $data['email_message'];
            $simplr_reg->default_email = $data['default_email'];
            $simplr_reg->stylesheet = $data['stylesheet'];
            $simplr_reg->styles = $data['styles'];
            $simplr_reg->style_skin = @$data['style_skin'] ? $data['style_skin'] : 'default.css';
            $simplr_reg->register_redirect = $data['register_redirect'];
            $simplr_reg->thank_you = $data['thank_you'];
            $simplr_reg->profile_redirect = $data['profile_redirect'];
            update_option('simplr_reg_options', $simplr_reg);
            simplr_set_message('updated notice is-dismissible', __("Your settings were saved.", 'simplr-registration-form'));
            wp_redirect($_SERVER['REQUEST_URI']);
        }
        if (@$_GET['action'] == 'delete') {
            /*Security First*/
            if (!check_admin_referer('delete', '_wpnonce')) {
                wp_die('Death to hackers');
            }
            $del = new SREG_Fields();
            $del->delete_field($_GET['key']);
            simplr_set_message('updated notice is-dismissible', __("Field deleted.", 'simplr-registration-form'));
            wp_redirect(remove_query_arg('action'));
        } elseif (isset($_POST['mass-submit'])) {
            if (!check_admin_referer(-1, '_mass_edit')) {
                wp_die('Death to hackers');
            }
            foreach ($_POST['field_to_delete'] as $key) {
                $del = new SREG_Fields();
                $del->delete_field($key);
            }
            simplr_set_message('updated notice is-dismissible', __("Fields were deleted.", 'simplr-registration-form'));
            wp_redirect(remove_query_arg('action'));
        }
        if (isset($_POST['submit-field'])) {
            if (!check_admin_referer(-1, 'reg-field')) {
                wp_die("Death to Hackers");
            }
            $new = new SREG_Fields();
            $key = $_POST['key'];
            $response = $new->save_custom($_POST);
            simplr_set_message('updated notice is-dismissible', __("Your Field was saved.", 'simplr-registration-form'));
            wp_redirect(remove_query_arg('action'));
        }
        add_action('admin_notices', 'simplr_print_message');
    }
}
function simplr_profile_init()
{
    global $simplr_options, $errors;
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('user-profile');
    $custom = new SREG_Fields();
    $fields = simplr_filter_profile_fields($custom->get_custom());
    set_transient('simplr_profile_transient', $fields);
    if (isset($_POST['simplr-profile'])) {
        if (!wp_verify_nonce($_POST['_simplr_nonce'], 'simplr-profile')) {
            wp_die('No hackers please! Your security nonce check failed. Please try again or contact the systems admin.');
        } else {
            $errors = simplr_validate_profile($_POST, $fields);
            $data = $_POST;
            if (!is_array($errors)) {
                //update user
                $userdata = array('ID' => $data['user_id'], 'user_nicename' => @$data['user_nicename'], 'user_email' => @$data['user_email']);
                if (isset($data['pass1']) and $data['pass1'] != '' and $data['pass2'] == $data['pass1']) {
                    $userdata['user_pass'] = $data['pass1'];
                }
                wp_update_user($userdata);
                //update user meta fields
                foreach ($fields as $field) {
                    if ($field['type'] == 'date') {
                        $dy = $data[$field['key'] . '-dy'];
                        $mo = $data[$field['key'] . '-mo'];
                        $yr = $data[$field['key'] . '-yr'];
                        $dateinput = implode('-', array($yr, $mo, $dy));
                        update_user_meta($data['user_id'], $field['key'], $dateinput);
                    } elseif ($field['type'] == 'checkbox') {
                        if (isset($data[$field['key']])) {
                            update_user_meta($data['user_id'], $field['key'], 'on');
                        } else {
                            delete_user_meta($data['user_id'], $field['key']);
                        }
                    } else {
                        update_user_meta($data['user_id'], $field['key'], $data[$field['key']]);
                    }
                }
                do_action('simplr_profile_save');
                wp_redirect('?p=' . $simplr_options->profile_redirect . '&updated=true');
            }
        }
    }
}
 function __construct()
 {
     parent::__construct();
     $this->cols = $this->cols();
 }