mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Added Login Checks
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
}
|
||||
|
||||
.um .um-single-image-preview > img {
|
||||
max-height: 200px;
|
||||
max-height: 300px;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
margin: auto;
|
||||
@@ -22,6 +22,9 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.um-single-image-preview.show,
|
||||
.um-single-file-preview.show {display: block}
|
||||
|
||||
.um-single-image-preview > img {
|
||||
max-width: 100%;
|
||||
max-height: inherit;
|
||||
@@ -47,8 +50,14 @@
|
||||
font-size: 16px;
|
||||
color: #888;
|
||||
position: relative;
|
||||
top: 4px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
line-height: 30px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.um-single-image-preview a.cancel i:before,
|
||||
.um-single-file-preview a.cancel i:before{line-height:inherit}
|
||||
|
||||
/*
|
||||
- file info
|
||||
@@ -60,7 +69,7 @@
|
||||
}
|
||||
|
||||
.um-single-fileinfo span.icon {
|
||||
font-size: 42px;
|
||||
font-size: 40px;
|
||||
display: inline-block;
|
||||
width: 100px;
|
||||
height: 70px;
|
||||
@@ -68,13 +77,19 @@
|
||||
background-color: #666;
|
||||
color: #fff !important;
|
||||
}
|
||||
.um-single-fileinfo span.icon i{vertical-align: middle}
|
||||
.um-single-fileinfo span.icon i {
|
||||
display: block;
|
||||
height: 70px;
|
||||
line-height: 70px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.um-single-fileinfo span.icon i:before{line-height:inherit}
|
||||
|
||||
.um-single-fileinfo span.filename {
|
||||
display: block;
|
||||
font-size: 16px;
|
||||
color: #888;
|
||||
padding: 15px 0 0 0;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.um-single-fileinfo a {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
.um-profile img {display: block;overflow:hidden;border-radius:0!important;margin: 0!important}
|
||||
.um-profile img {display: block;overflow:hidden;border-radius:0;margin: 0}
|
||||
|
||||
.um-profile a,
|
||||
.um-profile a:hover {text-decoration:none !important}
|
||||
@@ -82,7 +82,7 @@
|
||||
box-sizing: border-box;
|
||||
padding: 0 40px;
|
||||
color: #fff;
|
||||
text-shadow: 0 2px #333;
|
||||
text-shadow: 0 1px #666;
|
||||
cursor: pointer !important;
|
||||
line-height: 21px;
|
||||
font-size: 16px;
|
||||
@@ -200,17 +200,17 @@
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0,0,0,.5);
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
padding: 0 40px;
|
||||
color: #fff;
|
||||
text-shadow: 0 1px #666;
|
||||
cursor: pointer !important;
|
||||
line-height: 21px;
|
||||
font-size: 16px;
|
||||
text-shadow: 0 1px #333;
|
||||
cursor: pointer !important;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.um-profile-photo-overlay:hover {
|
||||
|
||||
@@ -459,7 +459,6 @@ div.uimob800 .um-header .um-profile-meta {
|
||||
padding-left: 200px;
|
||||
}
|
||||
|
||||
div.uimob800 .um-cover-overlay span.um-cover-overlay-t,
|
||||
div.uimob800 .um-profile-photo-overlay span.um-profile-photo-overlay-t
|
||||
{
|
||||
display: none !important;
|
||||
|
||||
+36
-15
@@ -155,6 +155,10 @@ p.um-notice.success {
|
||||
background: #7ACF58;
|
||||
}
|
||||
|
||||
p.um-notice.err {
|
||||
background: #C74A4A;
|
||||
}
|
||||
|
||||
/*
|
||||
- Errors
|
||||
*/
|
||||
@@ -276,19 +280,10 @@ p.um-notice.success {
|
||||
position: absolute;
|
||||
cursor: default;
|
||||
text-align: center !important;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
width: 50px;
|
||||
line-height: 34px;
|
||||
}
|
||||
.um-field-icon i:before { vertical-align: middle !important; margin: 0 auto !important; }
|
||||
|
||||
.um-field-icon i {
|
||||
font-size: 20px;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
top: 5px;
|
||||
left: 0;
|
||||
width: 44px;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.um-form input[type=text],
|
||||
@@ -315,7 +310,7 @@ p.um-notice.success {
|
||||
}
|
||||
|
||||
.um-form input[type=text].um-iconed,
|
||||
.um-form input[type=password].um-iconed { padding-left: 50px }
|
||||
.um-form input[type=password].um-iconed { padding-left: 44px }
|
||||
|
||||
.um-form input[type=text].um-error,
|
||||
.um-form input[type=password].um-error { border-color: #C74A4A !important }
|
||||
@@ -550,4 +545,30 @@ a.um-link-alt:hover {text-decoration: underline !important;}
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
z-index: 2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- Misc.
|
||||
*/
|
||||
|
||||
div.um-photo {
|
||||
margin: 20px auto 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.um-photo,
|
||||
div.um-photo a,
|
||||
div.um-photo img {
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
div.um-photo a {
|
||||
border: 1px solid #e5e5e5;
|
||||
padding: 5px;
|
||||
box-sizing: border-box;
|
||||
display: inline-block;
|
||||
box-shadow: 0 1px 1px #eee;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
div.um-photo img {max-height: 300px}
|
||||
+14
-9
@@ -1,8 +1,8 @@
|
||||
function initCrop_UM() {
|
||||
|
||||
// only when a crop image is in view
|
||||
var target_img = jQuery('.um-modal:visible .um-single-image-preview.crop img');
|
||||
var target_img_parent = jQuery('.um-modal:visible .um-single-image-preview.crop');
|
||||
var target_img = jQuery('.um-modal:visible .um-single-image-preview img');
|
||||
var target_img_parent = jQuery('.um-modal:visible .um-single-image-preview');
|
||||
|
||||
var crop_data = target_img.parent().attr('data-crop');
|
||||
var min_width = target_img.parent().attr('data-min_width');
|
||||
@@ -21,10 +21,8 @@ function initCrop_UM() {
|
||||
if ( target_img.attr('src') != '' ) {
|
||||
|
||||
var max_height = jQuery(window).height() - ( jQuery('.um-modal-footer a').height() + 20 ) - 50 - ( jQuery('.um-modal-header:visible').height() );
|
||||
|
||||
target_img.css({'height' : 'auto'});
|
||||
target_img_parent.css({'height' : 'auto'});
|
||||
|
||||
if ( jQuery(window).height() <= 400 ) {
|
||||
target_img_parent.css({ 'height': max_height +'px', 'max-height' : max_height + 'px' });
|
||||
target_img.css({ 'height' : 'auto' });
|
||||
@@ -32,7 +30,7 @@ function initCrop_UM() {
|
||||
target_img.css({ 'height': 'auto', 'max-height' : max_height + 'px' });
|
||||
target_img_parent.css({ 'height': target_img.height(), 'max-height' : max_height + 'px' });
|
||||
}
|
||||
|
||||
|
||||
if ( crop_data == 'square' ) {
|
||||
|
||||
var opts = {
|
||||
@@ -63,7 +61,7 @@ function initCrop_UM() {
|
||||
}
|
||||
};
|
||||
|
||||
} else {
|
||||
} else if ( crop_data == 'user' ) {
|
||||
|
||||
var opts = {
|
||||
dragCrop: true,
|
||||
@@ -78,7 +76,9 @@ function initCrop_UM() {
|
||||
|
||||
}
|
||||
|
||||
target_img.cropper( opts );
|
||||
if ( crop_data != 0 ) {
|
||||
target_img.cropper( opts );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ function um_modal_responsive() {
|
||||
|
||||
function um_remove_modal(){
|
||||
|
||||
jQuery('.um-single-image-preview img').cropper("destroy");
|
||||
jQuery('.um-modal .um-single-image-preview img').cropper("destroy");
|
||||
|
||||
jQuery('body,html').css("overflow", "auto");
|
||||
|
||||
@@ -229,7 +229,7 @@ jQuery(document).ready(function() {
|
||||
|
||||
var parent = jQuery(this).parents('.um-modal-body');
|
||||
|
||||
parent.find('.um-single-image-preview img').cropper("destroy");
|
||||
parent.find('.um-modal .um-single-image-preview img').cropper("destroy");
|
||||
|
||||
parent.find('.um-single-image-preview img').attr('src', '');
|
||||
|
||||
@@ -258,6 +258,8 @@ jQuery(document).ready(function() {
|
||||
|
||||
jQuery('.um-single-file-preview[data-key='+key+']').parents('.um-field').find('.um-btn-auto-width').html( jQuery(this).attr('data-change') );
|
||||
|
||||
jQuery('.um-single-file-preview[data-key='+key+']').parents('.um-field').find('input[type=hidden]').val( jQuery('.um-single-file-preview[data-key='+key+']').parents('.um-field').find('.um-single-fileinfo a').attr('href') );
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -317,6 +319,9 @@ jQuery(document).ready(function() {
|
||||
jQuery('.um-single-image-preview[data-key='+key+']').fadeIn().find('img').attr('src', src + "?"+d.getTime());
|
||||
um_remove_modal();
|
||||
jQuery('.um-single-image-preview[data-key='+key+']').parents('.um-field').find('.um-btn-auto-width').html( elem.attr('data-change') );
|
||||
|
||||
jQuery('.um-single-image-preview[data-key='+key+']').parents('.um-field').find('input[type=hidden]').val( src );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ jQuery(window).load(function() {
|
||||
/* Run only when window is resized */
|
||||
jQuery(window).resize(function() {
|
||||
|
||||
jQuery('.um-single-image-preview.crop:visible img').cropper("destroy");
|
||||
jQuery('.um-modal .um-single-image-preview.crop:visible img').cropper("destroy");
|
||||
|
||||
um_responsive();
|
||||
um_modal_responsive();
|
||||
|
||||
@@ -126,6 +126,7 @@ jQuery(document).ready(function() {
|
||||
var parent = jQuery(this).parents('.um-field');
|
||||
parent.find('.um-single-image-preview').hide();
|
||||
parent.find('.um-btn-auto-width').html('Upload');
|
||||
parent.find('input[type=hidden]').val('');
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -135,6 +136,7 @@ jQuery(document).ready(function() {
|
||||
var parent = jQuery(this).parents('.um-field');
|
||||
parent.find('.um-single-file-preview').hide();
|
||||
parent.find('.um-btn-auto-width').html('Upload');
|
||||
parent.find('input[type=hidden]').val('');
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
|
||||
do_action('um_submit_form_errors_hook_login', $args );
|
||||
|
||||
do_action('um_submit_form_errors_hook_logincheck', $args );
|
||||
|
||||
} else {
|
||||
|
||||
do_action('um_submit_form_errors_hook_', $args );
|
||||
|
||||
+32
-10
@@ -62,7 +62,6 @@
|
||||
switch( $err ) {
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
|
||||
case 'incorrect_password':
|
||||
@@ -78,6 +77,37 @@
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @login checks
|
||||
***/
|
||||
add_action('um_submit_form_errors_hook_logincheck', 'um_submit_form_errors_hook_logincheck', 9999 );
|
||||
function um_submit_form_errors_hook_logincheck($args){
|
||||
global $ultimatemember;
|
||||
|
||||
// Logout if logged in
|
||||
if ( is_user_logged_in() ) {
|
||||
wp_logout();
|
||||
}
|
||||
|
||||
$user_id = ( isset( $ultimatemember->login->auth_id ) ) ? $ultimatemember->login->auth_id : '';
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
$status = um_user('account_status'); // account status
|
||||
switch( $status ) {
|
||||
|
||||
// If user can't login to site...
|
||||
case 'inactive':
|
||||
case 'awaiting_admin_review':
|
||||
case 'awaiting_email_confirmation':
|
||||
case 'rejected':
|
||||
um_reset_user();
|
||||
exit( wp_redirect( add_query_arg( 'err', $status, $ultimatemember->permalinks->get_current_url() ) ) );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @login user
|
||||
***/
|
||||
@@ -85,16 +115,8 @@
|
||||
function um_user_login($args){
|
||||
global $ultimatemember;
|
||||
extract( $args );
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
wp_logout();
|
||||
}
|
||||
|
||||
$user_id = $ultimatemember->login->auth_id;
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
$ultimatemember->user->auto_login( $user_id );
|
||||
$ultimatemember->user->auto_login( um_user('ID') );
|
||||
|
||||
// Priority redirect
|
||||
if ( isset( $args['redirect_to'] ) ) {
|
||||
|
||||
@@ -49,22 +49,37 @@
|
||||
function um_add_update_notice($args){
|
||||
global $ultimatemember;
|
||||
extract($args);
|
||||
$output = '';
|
||||
|
||||
if ( isset( $_REQUEST['updated'] ) && !empty( $_REQUEST['updated'] ) ) {
|
||||
|
||||
switch( $_REQUEST['updated'] ) {
|
||||
|
||||
case 'password_changed':
|
||||
$msg = __('You have successfully changed your password.','ultimatemember');
|
||||
$success = __('You have successfully changed your password.','ultimatemember');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $msg ) ) {
|
||||
|
||||
echo '<p class="um-notice success">' . $msg . '</p>';
|
||||
|
||||
if ( isset( $_REQUEST['err'] ) && !empty( $_REQUEST['err'] ) ) {
|
||||
switch( $_REQUEST['err'] ) {
|
||||
case 'inactive':
|
||||
$err = __('Your account has been disabled.','ultimatemember');
|
||||
break;
|
||||
case 'awaiting_admin_review':
|
||||
$err = __('Your account has not been approved yet.','ultimatemember');
|
||||
break;
|
||||
case 'awaiting_email_confirmation':
|
||||
$err = __('Your account is awaiting e-mail verifications.','ultimatemember');
|
||||
break;
|
||||
case 'rejected':
|
||||
$err = __('Your membership request has been rejected.','ultimatemember');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $err ) ) {
|
||||
$output .= '<p class="um-notice err">' . $err . '</p>';
|
||||
}
|
||||
|
||||
echo $output;
|
||||
|
||||
}
|
||||
@@ -261,6 +261,7 @@
|
||||
global $ultimatemember;
|
||||
|
||||
$to_update = null;
|
||||
$files = null;
|
||||
|
||||
if ( isset( $args['user_id'] ) ) {
|
||||
if ( um_can_edit_profile( $args['user_id'] ) ) {
|
||||
@@ -289,6 +290,11 @@
|
||||
} else if ( $args['submitted'][$key] ) {
|
||||
$to_update[ $key ] = $args['submitted'][ $key ];
|
||||
}
|
||||
|
||||
// files
|
||||
if ( isset( $fields[$key]['type'] ) && in_array( $fields[$key]['type'], array('image','file') ) && um_is_temp_upload( $args['submitted'][ $key ] ) ) {
|
||||
$files[ $key ] = $args['submitted'][ $key ];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -296,6 +302,10 @@
|
||||
if ( is_array( $to_update ) ) {
|
||||
$ultimatemember->user->update_profile( $to_update );
|
||||
}
|
||||
|
||||
if ( is_array( $files ) ) {
|
||||
$ultimatemember->user->update_files( $files );
|
||||
}
|
||||
|
||||
do_action('um_user_after_updating_profile', $to_update );
|
||||
|
||||
|
||||
+47
-13
@@ -308,6 +308,8 @@ class UM_Fields {
|
||||
function field_value( $key, $default = false, $data = null ) {
|
||||
global $ultimatemember;
|
||||
|
||||
$type = (isset($data['type']))?$data['type']:'';
|
||||
|
||||
// preview in backend
|
||||
if ( isset( $ultimatemember->user->preview ) && $ultimatemember->user->preview ) {
|
||||
$submitted = um_user('submitted');
|
||||
@@ -336,6 +338,7 @@ class UM_Fields {
|
||||
$value = um_user( $key );
|
||||
$value = apply_filters("um_profile_field_filter_hook__", $value, $data );
|
||||
$value = apply_filters("um_profile_field_filter_hook__{$key}", $value, $data );
|
||||
$value = apply_filters("um_profile_field_filter_hook__{$type}", $value, $data );
|
||||
|
||||
return $value;
|
||||
|
||||
@@ -1002,19 +1005,33 @@ class UM_Fields {
|
||||
case 'image':
|
||||
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="'.$key.'">';
|
||||
|
||||
$output .= '<input type="hidden" name="'.$key.$ultimatemember->form->form_suffix.'" id="'.$key.$ultimatemember->form->form_suffix.'" value="'. $this->field_value( $key, $default, $data ) . '" />';
|
||||
|
||||
if ( isset( $data['label'] ) ) {
|
||||
$output .= $this->field_label($label, $key, $data);
|
||||
$output .= $this->field_label($label, $key, $data);
|
||||
}
|
||||
|
||||
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __('Upload Photo','ultimatemember');
|
||||
|
||||
$output .= '<div class="um-field-area" style="text-align: center">';
|
||||
|
||||
$output .= '<div class="um-field-area" style="text-align: center">
|
||||
if ( $this->field_value( $key, $default, $data ) ) {
|
||||
|
||||
<div class="um-single-image-preview '. $crop_class .'" data-crop="'.$crop_data.'" data-key="'.$key.'"><a href="#" class="cancel"><i class="um-icon-remove"></i></a><img src="" alt="" /></div>
|
||||
$output .= '<div class="um-single-image-preview show '. $crop_class .'" data-crop="'.$crop_data.'" data-key="'.$key.'">
|
||||
<a href="#" class="cancel"><i class="um-icon-remove"></i></a>
|
||||
<img src="' . um_user_uploads_uri() . $this->field_value( $key, $default, $data ) . '" alt="" />
|
||||
</div><a href="#" data-modal="um_upload_single" data-modal-size="'.$modal_size.'" data-modal-copy="1" class="um-button um-btn-auto-width">'. __('Change photo') . '</a>';
|
||||
|
||||
<a href="#" data-modal="um_upload_single" data-modal-size="'.$modal_size.'" data-modal-copy="1" class="um-button um-btn-auto-width">'. $button_text . '</a>
|
||||
} else {
|
||||
|
||||
$output .= '<div class="um-single-image-preview '. $crop_class .'" data-crop="'.$crop_data.'" data-key="'.$key.'">
|
||||
<a href="#" class="cancel"><i class="um-icon-remove"></i></a>
|
||||
<img src="" alt="" />
|
||||
</div><a href="#" data-modal="um_upload_single" data-modal-size="'.$modal_size.'" data-modal-copy="1" class="um-button um-btn-auto-width">'. $button_text . '</a>';
|
||||
|
||||
</div>';
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
/* modal hidden */
|
||||
$output .= '<div class="um-modal-hidden-content">';
|
||||
@@ -1060,21 +1077,38 @@ class UM_Fields {
|
||||
case 'file':
|
||||
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="'.$key.'">';
|
||||
|
||||
$output .= '<input type="hidden" name="'.$key.$ultimatemember->form->form_suffix.'" id="'.$key.$ultimatemember->form->form_suffix.'" value="'. $this->field_value( $key, $default, $data ) . '" />';
|
||||
|
||||
if ( isset( $data['label'] ) ) {
|
||||
$output .= $this->field_label($label, $key, $data);
|
||||
}
|
||||
|
||||
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __('Upload Photo','ultimatemember');
|
||||
|
||||
$output .= '<div class="um-field-area" style="text-align: center">
|
||||
$output .= '<div class="um-field-area" style="text-align: center">';
|
||||
|
||||
<div class="um-single-file-preview" data-key="'.$key.'">
|
||||
if ( $this->field_value( $key, $default, $data ) ) {
|
||||
|
||||
$extension = pathinfo( $this->field_value( $key, $default, $data ), PATHINFO_EXTENSION);
|
||||
|
||||
$output .= '<div class="um-single-file-preview show" data-key="'.$key.'">
|
||||
<a href="#" class="cancel"><i class="um-icon-remove"></i></a>
|
||||
<div class="um-single-fileinfo">
|
||||
<a href="' . um_user_uploads_uri() . $this->field_value( $key, $default, $data ) . '" target="_blank">
|
||||
<span class="icon" style="background:'. $ultimatemember->files->get_fonticon_bg_by_ext( $extension ) . '"><i class="'. $ultimatemember->files->get_fonticon_by_ext( $extension ) .'"></i></span>
|
||||
<span class="filename">' . $this->field_value( $key, $default, $data ) . '</span>
|
||||
</a>
|
||||
</div>
|
||||
</div><a href="#" data-modal="um_upload_single" data-modal-size="'.$modal_size.'" data-modal-copy="1" class="um-button um-btn-auto-width">'. __('Change file') . '</a>';
|
||||
|
||||
} else {
|
||||
|
||||
$output .= '<div class="um-single-file-preview" data-key="'.$key.'">
|
||||
</div><a href="#" data-modal="um_upload_single" data-modal-size="'.$modal_size.'" data-modal-copy="1" class="um-button um-btn-auto-width">'. $button_text . '</a>';
|
||||
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
<a href="#" data-modal="um_upload_single" data-modal-size="'.$modal_size.'" data-modal-copy="1" class="um-button um-btn-auto-width">'. $button_text . '</a>
|
||||
|
||||
</div>';
|
||||
$output .= '</div>';
|
||||
|
||||
/* modal hidden */
|
||||
$output .= '<div class="um-modal-hidden-content">';
|
||||
@@ -1094,7 +1128,7 @@ class UM_Fields {
|
||||
$output .= '<div class="um-single-file-preview">
|
||||
<a href="#" class="cancel"><i class="um-icon-remove"></i></a>
|
||||
<div class="um-single-fileinfo">
|
||||
<a href="#" target="_blank">
|
||||
<a href="" target="_blank">
|
||||
<span class="icon"><i></i></span>
|
||||
<span class="filename"></span>
|
||||
</a>
|
||||
|
||||
+5
-5
@@ -411,8 +411,8 @@ class UM_Files {
|
||||
$ext = '.' . pathinfo($source_name, PATHINFO_EXTENSION);
|
||||
$name = str_replace( $ext, '', $source_name );
|
||||
$filename = $name . $ext;
|
||||
|
||||
// copy image
|
||||
|
||||
// copy file
|
||||
copy( $source, $this->upload_basedir . $user_id . '/' . $filename );
|
||||
|
||||
// thumbs
|
||||
@@ -466,15 +466,15 @@ class UM_Files {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// clean up temp
|
||||
$dir = dirname( $source );
|
||||
unlink( $source );
|
||||
rmdir( $dir );
|
||||
|
||||
|
||||
// update user's meta
|
||||
update_user_meta( $user_id, $key, $filename );
|
||||
|
||||
|
||||
// the url of upload
|
||||
return $this->upload_baseurl . $user_id . '/' . $filename;
|
||||
|
||||
|
||||
+45
-10
@@ -1,5 +1,49 @@
|
||||
<?php
|
||||
|
||||
/***
|
||||
*** @Images
|
||||
***/
|
||||
add_filter('um_profile_field_filter_hook__file', 'um_profile_field_filter_hook__file', 99, 2);
|
||||
function um_profile_field_filter_hook__file( $value, $data ) {
|
||||
global $ultimatemember;
|
||||
|
||||
$uri = um_user_uploads_uri() . $value;
|
||||
$extension = pathinfo( $uri, PATHINFO_EXTENSION);
|
||||
|
||||
if ( !file_exists( um_user_uploads_dir() . $value ) ) {
|
||||
$value = __('This file has been removed.');
|
||||
} else {
|
||||
$value = '<div class="um-single-file-preview show">
|
||||
<div class="um-single-fileinfo">
|
||||
<a href="' . $uri . '" target="_blank">
|
||||
<span class="icon" style="background:'. $ultimatemember->files->get_fonticon_bg_by_ext( $extension ) . '"><i class="'. $ultimatemember->files->get_fonticon_by_ext( $extension ) .'"></i></span>
|
||||
<span class="filename">' . $value . '</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Files
|
||||
***/
|
||||
add_filter('um_profile_field_filter_hook__image', 'um_profile_field_filter_hook__image', 99, 2);
|
||||
function um_profile_field_filter_hook__image( $value, $data ) {
|
||||
|
||||
$uri = um_user_uploads_uri() . $value;
|
||||
$title = ( isset( $data['title'] ) ) ? $data['title'] : __('Untitled photo');
|
||||
|
||||
if ( !file_exists( um_user_uploads_dir() . $value ) ) {
|
||||
$value = __('Image has been removed.');
|
||||
} else {
|
||||
$value = '<div class="um-photo"><a href="#"><img src="'. $uri .'" alt="'.$title.'" title="'.$title.'" class="" /></a></div>';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @some required changes before value is shown
|
||||
***/
|
||||
@@ -9,7 +53,6 @@
|
||||
if ( isset( $data['validate'] ) && $data['validate'] != '' && strstr( $data['validate'], 'url' ) ) {
|
||||
$alt = ( isset( $data['url_text'] ) ) ? $data['url_text'] : $value;
|
||||
$url_rel = ( isset( $data['url_rel'] ) ) ? 'rel="nofollow"' : '';
|
||||
|
||||
if( !strstr( $value, 'http' )
|
||||
&& !strstr( $value, '://' )
|
||||
&& !strstr( $value, 'www.' )
|
||||
@@ -17,32 +60,24 @@
|
||||
&& !strstr( $value, '.net' )
|
||||
&& !strstr( $value, '.org' )
|
||||
) {
|
||||
|
||||
if ( $data['validate'] == 'facebook_url' ) $value = 'http://facebook.com/' . $value;
|
||||
if ( $data['validate'] == 'twitter_url' ) $value = 'http://twitter.com/' . $value;
|
||||
if ( $data['validate'] == 'linkedin_url' ) $value = 'http://linkedin.com/' . $value;
|
||||
if ( $data['validate'] == 'skype' ) $value = 'http://skype.com/' . $value;
|
||||
if ( $data['validate'] == 'googleplus_url' ) $value = 'http://plus.google.com/' . $value;
|
||||
if ( $data['validate'] == 'instagram_url' ) $value = 'http://instagram.com/' . $value;
|
||||
|
||||
if ( $data['validate'] == 'instagram_url' ) $value = 'http://instagram.com/' . $value;
|
||||
}
|
||||
|
||||
if ( strpos($value, 'http://') !== 0 ) {
|
||||
$value = 'http://' . $value;
|
||||
}
|
||||
|
||||
$value = '<a href="'. $value .'" target="'.$data['url_target'].'" ' . $url_rel . '>'.$alt.'</a>';
|
||||
}
|
||||
|
||||
if ( !is_array( $value ) ) {
|
||||
|
||||
if ( is_email( $value ) )
|
||||
$value = '<a href="mailto:'. $value.'">'.$value.'</a>';
|
||||
|
||||
} else {
|
||||
|
||||
$value = implode(', ', $value);
|
||||
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
+2
-1
@@ -12,7 +12,7 @@ class UM_Form {
|
||||
|
||||
$this->errors = null;
|
||||
|
||||
add_action('init', array(&$this, 'form_init'), 1);
|
||||
add_action('init', array(&$this, 'form_init'), 2);
|
||||
|
||||
add_action('init', array(&$this, 'field_declare'), 10);
|
||||
|
||||
@@ -88,6 +88,7 @@ class UM_Form {
|
||||
|
||||
do_action("um_submit_form_errors_hook", $this->post_form );
|
||||
|
||||
|
||||
do_action("um_submit_form_{$this->post_form['mode']}", $this->post_form );
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,21 @@
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Check that temp upload is valid
|
||||
***/
|
||||
function um_is_temp_upload( $url ) {
|
||||
global $ultimatemember;
|
||||
$url = explode('/ultimatemember/temp/', $url);
|
||||
if ( isset( $url[1] ) ) {
|
||||
$src = $ultimatemember->files->upload_temp . $url[1];
|
||||
if ( !file_exists( $src ) )
|
||||
return false;
|
||||
return $src;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Check that temp image is valid
|
||||
@@ -21,16 +36,12 @@
|
||||
global $ultimatemember;
|
||||
$url = explode('/ultimatemember/temp/', $url);
|
||||
if ( isset( $url[1] ) ) {
|
||||
|
||||
$src = $ultimatemember->files->upload_temp . $url[1];
|
||||
|
||||
if ( !file_exists( $src ) )
|
||||
return false;
|
||||
|
||||
list($width, $height, $type, $attr) = @getimagesize($src);
|
||||
if ( isset( $width ) && isset( $height ) )
|
||||
return $src;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -440,6 +451,18 @@
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @user uploads directory
|
||||
***/
|
||||
function um_user_uploads_dir() {
|
||||
global $ultimatemember;
|
||||
$uri = $ultimatemember->files->upload_basedir . um_user('ID') . '/';
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @find closest number in an array
|
||||
***/
|
||||
function um_closest_num($array, $number) {
|
||||
sort($array);
|
||||
foreach ($array as $a) {
|
||||
|
||||
+15
-1
@@ -21,7 +21,7 @@ class UM_User {
|
||||
|
||||
$this->preview = false;
|
||||
|
||||
// needs to be updated by wp_update_user()
|
||||
// a list of keys that should be done on wp_update_user
|
||||
$this->update_user_keys = array(
|
||||
'user_email',
|
||||
'user_pass',
|
||||
@@ -406,6 +406,20 @@ class UM_User {
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @update files
|
||||
***/
|
||||
function update_files( $array ) {
|
||||
|
||||
global $ultimatemember;
|
||||
|
||||
foreach( $array as $key => $uri ) {
|
||||
$src = um_is_temp_upload( $uri );
|
||||
$ultimatemember->files->new_user_upload( $this->id, $src, $key );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @update profile
|
||||
***/
|
||||
|
||||
Reference in New Issue
Block a user