Permalink
Browse files

Fix account fields update

  • Loading branch information...
champsupertramp committed May 26, 2016
1 parent cfada53 commit a2b24d145ce6c2c33333a770703181d83c88258e
Showing with 52 additions and 6 deletions.
  1. +13 −1 core/um-account.php
  2. +15 −2 core/um-actions-account.php
  3. +24 −3 core/um-filters-account.php
@@ -150,7 +150,7 @@ function get_tab_output( $id ) {
global $ultimatemember;
$output = null;
switch( $id ) {
case 'notifications':
@@ -166,6 +166,9 @@ function get_tab_output( $id ) {
$args = apply_filters('um_account_tab_privacy_fields', $args );
$fields = $ultimatemember->builtin->get_specific_fields( $args );
$fields = apply_filters('um_account_secure_fields', $fields, $id );
foreach( $fields as $key => $data ){
$output .= $ultimatemember->fields->edit_field( $key, $data );
}
@@ -179,6 +182,9 @@ function get_tab_output( $id ) {
$args = 'single_user_password';
$fields = $ultimatemember->builtin->get_specific_fields( $args );
$fields = apply_filters('um_account_secure_fields', $fields, $id );
foreach( $fields as $key => $data ){
$output .= $ultimatemember->fields->edit_field( $key, $data );
}
@@ -200,6 +206,9 @@ function get_tab_output( $id ) {
}
$fields = $ultimatemember->builtin->get_specific_fields( $args );
$fields = apply_filters('um_account_secure_fields', $fields, $id );
foreach( $fields as $key => $data ){
$output .= $ultimatemember->fields->edit_field( $key, $data );
}
@@ -213,6 +222,9 @@ function get_tab_output( $id ) {
$args = 'user_password';
$fields = $ultimatemember->builtin->get_specific_fields( $args );
$fields = apply_filters('um_account_secure_fields', $fields, $id );
foreach( $fields as $key => $data ){
$output .= $ultimatemember->fields->edit_field( $key, $data );
}
@@ -15,11 +15,24 @@ function um_submit_account_details( $args ) {
}
$arr_fields = array();
$secure_fields = get_user_meta( um_user('ID'), 'um_account_secure_fields', true );
if( isset( $secure_fields ) ){
foreach ( $secure_fields as $tab_key => $fields ) {
if( isset( $fields ) ){
foreach ($fields as $key => $value) {
$arr_fields[ ] = $key;
}
}
}
}
$changes = array();
foreach( $_POST as $k => $v ) {
if ( !strstr( $k, 'password' ) && !strstr( $k, 'um_account' ) ) {
if ( !strstr( $k, 'password' ) && !strstr( $k, 'um_account' ) && in_array( $k, $arr_fields ) ) {
$changes[ $k ] = $v;
}
}
}
if ( isset( $changes['hide_in_members'] ) && $changes['hide_in_members'] == __('No','ultimatemember') ) {
delete_user_meta( um_user('ID'), 'hide_in_members' );
@@ -1,8 +1,12 @@
<?php
/***
*** @Adjust available tabs
***/
/**
* Account default tabs
* @param array $tabs
* @return array $tabs
* @uses um_account_page_default_tabs_hook
*/
add_filter('um_account_page_default_tabs_hook', 'um_account_page_default_tabs_hook' );
function um_account_page_default_tabs_hook( $tabs ) {
global $ultimatemember;
@@ -26,4 +30,21 @@ function um_account_page_default_tabs_hook( $tabs ) {
return $tabs;
}
/**
* Account secure fields
* @param array $fields
* @param string $tab_key
* @return array
* @uses um_account_secure_fields
*/
add_filter('um_account_secure_fields','um_account_secure_fields', 10, 2);
function um_account_secure_fields( $fields, $tab_key ){
$_SESSION['um_account_fields'][ $tab_key ] = $fields;
update_user_meta( um_user('ID'), 'um_account_secure_fields', $_SESSION['um_account_fields'] );
return $fields;
}

0 comments on commit a2b24d1

Please sign in to comment.