diff --git a/admin/core/um-admin-metabox.php b/admin/core/um-admin-metabox.php index ddd6fa71..92456cdd 100644 --- a/admin/core/um-admin-metabox.php +++ b/admin/core/um-admin-metabox.php @@ -244,6 +244,8 @@ class UM_Admin_Metabox { add_meta_box('um-admin-form-register_customize', __('Customize this form'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); add_meta_box('um-admin-form-profile_customize', __('Customize this form'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); add_meta_box('um-admin-form-login_customize', __('Customize this form'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); + + add_meta_box('um-admin-form-login_settings', __('Settings'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); } diff --git a/admin/templates/form/login_settings.php b/admin/templates/form/login_settings.php new file mode 100644 index 00000000..d3272084 --- /dev/null +++ b/admin/templates/form/login_settings.php @@ -0,0 +1,20 @@ +
+ +

+ +

+ +

+ + +

+ +
\ No newline at end of file diff --git a/admin/templates/role/login.php b/admin/templates/role/login.php index 6afe0c33..8f0342b3 100644 --- a/admin/templates/role/login.php +++ b/admin/templates/role/login.php @@ -10,6 +10,7 @@ + diff --git a/core/um-access.php b/core/um-access.php index 6e4c06b6..b7b7c8ce 100644 --- a/core/um-access.php +++ b/core/um-access.php @@ -57,7 +57,7 @@ class UM_Access { $args = $this->get_meta(); extract($args); - $redirect = null; + $redirect_to = null; if ( !isset( $accessible ) ) return; @@ -69,24 +69,24 @@ class UM_Access { case 1: if ( is_user_logged_in() ) - $redirect = $access_redirect2; + $redirect_to = $access_redirect2; break; case 2: if ( !is_user_logged_in() ) - $redirect = $access_redirect; + $redirect_to = $access_redirect; if ( isset( $access_roles ) && !empty( $access_roles ) ) if ( !in_array( um_user('role'), unserialize( $access_roles ) ) ) - $redirect = $access_redirect; + $redirect_to = $access_redirect; break; } - if ( $redirect ) { - wp_redirect( $redirect ); + if ( $redirect_to ) { + wp_redirect( $redirect_to ); exit; } diff --git a/core/um-actions-login.php b/core/um-actions-login.php index 51b85af5..07ca5ab4 100644 --- a/core/um-actions-login.php +++ b/core/um-actions-login.php @@ -85,6 +85,10 @@ function um_user_login($args){ global $ultimatemember; extract( $args ); + + if ( is_user_logged_in() ) { + wp_logout(); + } $user_id = $ultimatemember->login->auth_id; @@ -92,9 +96,19 @@ $ultimatemember->user->auto_login( $user_id ); + // Priority redirect + if ( isset( $args['redirect_to'] ) ) { + exit( wp_redirect( $args['redirect_to'] ) ); + } + + // Role redirect $after = um_user('after_login'); switch( $after ) { + case 'redirect_admin': + exit( wp_redirect( admin_url() ) ); + break; + case 'redirect_profile': exit( wp_redirect( um_user_profile_url() ) ); break; diff --git a/core/um-actions-misc.php b/core/um-actions-misc.php new file mode 100644 index 00000000..7d102ad0 --- /dev/null +++ b/core/um-actions-misc.php @@ -0,0 +1,70 @@ +'; + + } + + if ( isset( $args['after_login'] ) && !empty( $args['after_login'] ) ) { + + switch( $args['after_login'] ) { + + case 'redirect_admin': + $url = admin_url(); + break; + + case 'redirect_profile': + $url = um_user_profile_url(); + break; + + case 'redirect_url': + $url = $args['redirect_url']; + break; + + case 'refresh': + $url = $ultimatemember->permalinks->get_current_url(); + break; + + } + + echo ''; + + } + + } + + /*** + *** @add a notice to form + ***/ + add_action('um_before_form', 'um_add_update_notice', 500 ); + function um_add_update_notice($args){ + global $ultimatemember; + extract($args); + if ( isset( $_REQUEST['updated'] ) && !empty( $_REQUEST['updated'] ) ) { + + switch( $_REQUEST['updated'] ) { + + case 'password_changed': + $msg = __('You have successfully changed your password.','ultimatemember'); + break; + + } + + } + + if ( isset( $msg ) ) { + + echo '

' . $msg . '

'; + + } + + } \ No newline at end of file diff --git a/core/um-actions-notices.php b/core/um-actions-notices.php deleted file mode 100644 index 2c9e9869..00000000 --- a/core/um-actions-notices.php +++ /dev/null @@ -1,28 +0,0 @@ -' . $msg . '

'; - - } - - } \ No newline at end of file diff --git a/core/um-logout.php b/core/um-logout.php index 5720d5cc..b2984cde 100644 --- a/core/um-logout.php +++ b/core/um-logout.php @@ -18,15 +18,16 @@ class UM_Logout { if ( is_user_logged_in() ) { if ( isset($_REQUEST['redirect_to']) && $_REQUEST['redirect_to'] !== '' ) { - $redirect = $_REQUEST['redirect_to']; + $redirect_to = $_REQUEST['redirect_to']; } else if ( um_user('after_logout') == 'redirect_home' ) { - $redirect = home_url(); + $redirect_to = home_url(); } else { - $redirect = um_user('logout_redirect_url'); + $redirect_to = um_user('logout_redirect_url'); } wp_logout(); - exit( wp_redirect( $redirect ) ); + + exit( wp_redirect( $redirect_to ) ); } else { exit( wp_redirect( home_url() ) ); diff --git a/core/um-setup.php b/core/um-setup.php index 964e1f91..d8116908 100644 --- a/core/um-setup.php +++ b/core/um-setup.php @@ -182,7 +182,7 @@ class UM_Setup { 'default_homepage' => 1, 'status' => 'approved', 'auto_approve_act' => 'redirect_profile', - 'after_login' => 'redirect_profile', + 'after_login' => 'redirect_admin', 'after_logout' => 'redirect_home', ); @@ -196,6 +196,7 @@ class UM_Setup { 'can_delete_roles' => 0, 'can_make_private_profile' => 0, 'can_access_private_profile' => 0, + 'after_login' => 'redirect_profile', ); } diff --git a/um-init.php b/um-init.php index ad25f053..0dd2818d 100644 --- a/um-init.php +++ b/um-init.php @@ -66,7 +66,7 @@ class UM_API { require_once um_path . 'core/um-actions-user.php'; require_once um_path . 'core/um-actions-save-profile.php'; require_once um_path . 'core/um-actions-modal.php'; - require_once um_path . 'core/um-actions-notices.php'; + require_once um_path . 'core/um-actions-misc.php'; require_once um_path . 'core/um-filters-login.php'; require_once um_path . 'core/um-filters-register.php';