From 99c55a224c9dc7850f8914a7cb4eb7bc56fbb78c Mon Sep 17 00:00:00 2001 From: jonfalcon Date: Sun, 31 Jan 2016 13:39:49 -0800 Subject: [PATCH] Fix account page using other user's info --- core/um-account.php | 172 ++++++++++++++++++++++---------------------- 1 file changed, 87 insertions(+), 85 deletions(-) diff --git a/core/um-account.php b/core/um-account.php index 2a786194..1750a8ae 100644 --- a/core/um-account.php +++ b/core/um-account.php @@ -3,44 +3,44 @@ class UM_Account { function __construct() { - + add_shortcode('ultimatemember_account', array(&$this, 'ultimatemember_account'), 1); - + add_filter('um_account_page_default_tabs_hook', array(&$this, 'core_tabs'), 1); - + add_action('template_redirect', array(&$this, 'account'), 10001 ); - + add_action('template_redirect', array(&$this, 'form_init'), 10002); - + add_filter('um_predefined_fields_hook', array(&$this,'predefined_fields_hook'),1 ); $this->current_tab = 'general'; } - + /*** *** @get core account tabs ***/ function core_tabs() { - + $tabs[100]['general']['icon'] = 'um-faicon-user'; $tabs[100]['general']['title'] = __('Account','ultimatemember'); - + $tabs[200]['password']['icon'] = 'um-faicon-asterisk'; $tabs[200]['password']['title'] = __('Change Password','ultimatemember'); - + $tabs[300]['privacy']['icon'] = 'um-faicon-lock'; $tabs[300]['privacy']['title'] = __('Privacy','ultimatemember'); - + $tabs[400]['notifications']['icon'] = 'um-faicon-envelope'; $tabs[400]['notifications']['title'] = __('Notifications','ultimatemember'); - + $tabs[9999]['delete']['icon'] = 'um-faicon-trash-o'; $tabs[9999]['delete']['title'] = __('Delete Account','ultimatemember'); - + return $tabs; } - + /*** *** @account page form ***/ @@ -48,17 +48,17 @@ class UM_Account { global $ultimatemember; if ( um_submitting_account_page() ) { - + $ultimatemember->form->post_form = $_POST; do_action('um_submit_account_errors_hook', $ultimatemember->form->post_form ); - + if ( !isset($ultimatemember->form->errors) ) { - + if ( get_query_var('um_tab') ) { $this->current_tab = get_query_var('um_tab'); } - + do_action('um_submit_account_details', $ultimatemember->form->post_form ); } @@ -66,177 +66,179 @@ class UM_Account { } } - + /*** *** @can access account page ***/ function account(){ global $ultimatemember; - + if ( um_is_core_page('account') && !is_user_logged_in() ) { exit( wp_redirect( add_query_arg('redirect_to', urlencode( um_get_core_page('account') ) , um_get_core_page('login') ) ) ); } - + if ( um_is_core_page('account') ) { - + $ultimatemember->fields->set_mode = 'account'; - + $ultimatemember->fields->editing = true; - + if ( get_query_var('um_tab') ) { $this->current_tab = get_query_var('um_tab'); } - + } - + } - + /*** *** @get tab link ***/ function tab_link( $id ) { - + if ( get_option('permalink_structure') ) { - + $url = trailingslashit( untrailingslashit( um_get_core_page('account') ) ); $url = $url . $id . '/'; - + } else { - + $url = add_query_arg( 'um_tab', $id, um_get_core_page('account') ); - + } - + return $url; } - + /*** *** @Add class based on shortcode ***/ function get_class( $mode ){ - + global $ultimatemember; - + $classes = 'um-'.$mode; - + if ( is_admin() ) { $classes .= ' um-in-admin'; } - + if ( $ultimatemember->fields->editing == true ) { $classes .= ' um-editing'; } - + if ( $ultimatemember->fields->viewing == true ) { $classes .= ' um-viewing'; } - + $classes = apply_filters('um_form_official_classes__hook', $classes); return $classes; } - + /*** *** @get tab output ***/ function get_tab_output( $id ) { global $ultimatemember; - + $output = null; - + switch( $id ) { - + case 'notifications': - + $output = apply_filters("um_account_content_hook_{$id}", $output); return $output; - + break; case 'privacy': - + $args = 'profile_privacy,hide_in_members'; $args = apply_filters('um_account_tab_privacy_fields', $args ); - + $fields = $ultimatemember->builtin->get_specific_fields( $args ); foreach( $fields as $key => $data ){ $output .= $ultimatemember->fields->edit_field( $key, $data ); } - + return $output; - + break; - + case 'delete': - + $args = 'single_user_password'; - + $fields = $ultimatemember->builtin->get_specific_fields( $args ); foreach( $fields as $key => $data ){ $output .= $ultimatemember->fields->edit_field( $key, $data ); } - + return $output; - + break; - + case 'general': - + $args = 'user_login,first_name,last_name,user_email'; - + if ( !um_get_option('account_name') ) { $args = 'user_login,user_email'; } - + if ( !um_get_option('account_email') && !um_user('can_edit_everyone') ) { $args = str_replace(',user_email','', $args ); } - + $fields = $ultimatemember->builtin->get_specific_fields( $args ); foreach( $fields as $key => $data ){ $output .= $ultimatemember->fields->edit_field( $key, $data ); } - + return $output; - + break; - + case 'password': - + $args = 'user_password'; - + $fields = $ultimatemember->builtin->get_specific_fields( $args ); foreach( $fields as $key => $data ){ $output .= $ultimatemember->fields->edit_field( $key, $data ); } - + return $output; - + break; - + default : - + $output = apply_filters("um_account_content_hook_{$id}", $output); return $output; - + break; } } - + /*** *** @Shortcode ***/ function ultimatemember_account( $args = array() ) { return $this->load( $args ); } - + /*** *** @Load a module with global function ***/ function load( $args ) { - + global $ultimatemember; - + + $ultimatemember->user->set( get_current_user_id() ); + ob_start(); $defaults = array( @@ -245,35 +247,35 @@ class UM_Account { 'form_id' => 'um_account_id', ); $args = wp_parse_args( $args, $defaults ); - + if ( isset( $args['use_globals'] ) && $args['use_globals'] == 1 ) { $args = array_merge( $args, $this->get_css_args( $args ) ); } else { $args = array_merge( $this->get_css_args( $args ), $args ); } - + $args = apply_filters('um_account_shortcode_args_filter', $args); extract( $args, EXTR_SKIP ); - + do_action("um_pre_{$mode}_shortcode", $args); - + do_action("um_before_form_is_loaded", $args); - + do_action("um_before_{$mode}_form_is_loaded", $args); - + $this->template_load( $template, $args ); - + if ( !is_admin() && !defined( 'DOING_AJAX' ) ) { $this->dynamic_css( $args ); } - + $output = ob_get_contents(); ob_end_clean(); return $output; } - + /*** *** @Get dynamic css args ***/ @@ -282,7 +284,7 @@ class UM_Account { $arr = array_merge( $arr, array( 'form_id' => $args['form_id'], 'mode' => $args['mode'] ) ); return $arr; } - + /*** *** @Load dynamic css ***/ @@ -315,7 +317,7 @@ class UM_Account { if( ! $account_hide_in_directory ){ unset( $predefined_fields['hide_in_members'] ); } - + return $predefined_fields; } -} \ No newline at end of file +}