Version 1.0.21

This commit is contained in:
ultimatemember
2015-01-24 23:39:43 +02:00
parent 63820a8ad8
commit 2c3cf6ea8c
22 changed files with 468 additions and 43 deletions
+1 -2
View File
@@ -30,9 +30,8 @@ class UM_Access {
/***
*** @get meta
***/
function get_meta() {
function get_meta( $post_id ) {
global $post;
$post_id = $post->ID;
$meta = get_post_custom( $post_id );
foreach ($meta as $k => $v){
if ( strstr($k, '_um_') ) {
+15 -3
View File
@@ -56,11 +56,23 @@
function um_access_post_settings() {
global $post, $ultimatemember;
if ( !get_post_type() || !isset($post->ID) ) return;
// woo commerce shop ID
if( function_exists('is_shop') && is_shop() ) {
$post_id = get_option('woocommerce_shop_page_id');
} else {
if ( !get_post_type() || !isset($post->ID) ) return;
}
$args = $ultimatemember->access->get_meta();
if ( !isset( $post_id ) )
$post_id = $post->ID;
$args = $ultimatemember->access->get_meta( $post_id );
extract($args);
if ( !isset( $args['custom_access_settings'] ) || $args['custom_access_settings'] == 0 ) return;
$redirect_to = null;
+19
View File
@@ -92,4 +92,23 @@
if(is_array($output)){ print_r($output); }else{ echo $output; } die;
}
/***
*** @run an ajax action on the fly
***/
add_action('wp_ajax_nopriv_ultimatemember_muted_action', 'ultimatemember_muted_action');
add_action('wp_ajax_ultimatemember_muted_action', 'ultimatemember_muted_action');
function ultimatemember_muted_action(){
global $ultimatemember;
extract($_REQUEST);
if ( !um_current_user_can('edit', $user_id ) ) die( __('You can not edit this user') );
switch( $hook ) {
default:
do_action("um_run_ajax_function__{$hook}", $_REQUEST);
break;
}
}
+15 -1
View File
@@ -38,9 +38,10 @@
wp_set_password( $args['user_password'], $args['user_id'] );
delete_user_meta( $args['user_id'], 'reset_pass_hash');
delete_user_meta( $args['user_id'], 'reset_pass_hash_token');
do_action('um_after_changing_user_password', $args['user_id'] );
if ( is_user_logged_in() ) {
wp_logout();
}
@@ -49,6 +50,19 @@
}
/***
*** @This is executed after changing password
***/
add_action('um_after_changing_user_password','um_after_changing_user_password');
function um_after_changing_user_password( $user_id ) {
global $ultimatemember;
um_fetch_user( $user_id );
$ultimatemember->mail->send( um_user('user_email'), 'changedpw_email' );
um_reset_user();
}
/***
*** @Error handler: reset password
***/
+77
View File
@@ -1,5 +1,27 @@
<?php
/***
*** @um_profile_content_{main_tab}
***/
add_action('um_profile_content_main','um_profile_content_main');
function um_profile_content_main( $args ) {
extract( $args );
do_action("um_before_form", $args);
do_action("um_before_{$template}_fields", $args);
do_action("um_main_{$template}_fields", $args);
do_action("um_after_form_fields", $args);
do_action("um_after_{$template}_fields", $args);
do_action("um_after_form", $args);
}
/***
*** @update user's profile
***/
@@ -474,4 +496,59 @@
</div>
<?php
}
/***
*** @display the available profile tabs
***/
add_action('um_profile_navbar', 'um_profile_navbar');
function um_profile_navbar( $args ) {
global $ultimatemember;
$tabs = $ultimatemember->profile->tabs();
if ( count( $tabs ) == 1 ) return;
$active_tab = $ultimatemember->profile->active_tab;
?>
<div class="um-profile-nav">
<?php foreach( $tabs as $id => $tab ) {
$nav_link = $ultimatemember->permalinks->get_current_url(true);
$nav_link = add_query_arg('profiletab', $id, $nav_link )
?>
<div class="um-profile-nav-item <?php if ( $id == $active_tab ) echo 'active'; ?>"><a href="<?php echo $nav_link; ?>" title="<?php echo $tab['name']; ?>"><i class="<?php echo $tab['icon']; ?> uimob500-show uimob340-show uimob800-show"></i><span class="uimob500-hide uimob340-hide uimob800-hide"><?php echo $tab['name']; ?></span></a></div>
<?php } ?>
<div class="um-clear"></div>
</div>
<?php
foreach( $tabs as $id => $tab ) {
if ( isset( $tab['subnav'] ) && $active_tab == $id ) {
$active_subnav = (isset($ultimatemember->profile->active_subnav)) ? $ultimatemember->profile->active_subnav : $tab['subnav_default'];
echo '<div class="um-profile-subnav">';
foreach( $tab['subnav'] as $id => $subtab ) {
?>
<a href="<?php echo add_query_arg('subnav', $id ); ?>" class="<?php if ( $active_subnav == $id ) echo 'active'; ?>"><?php echo $subtab; ?></a>
<?php
}
echo '</div>';
}
}
}
+2 -2
View File
@@ -11,6 +11,8 @@
if ( $changes['first_name'] && $changes['last_name'] ) {
wp_update_user( array( 'ID' => $ultimatemember->user->id, 'display_name' => $changes['first_name'] . ' ' . $changes['last_name'] ) );
$full_name = $changes['first_name'] . '.' . $changes['last_name'];
} else {
@@ -21,8 +23,6 @@
$full_name = $ultimatemember->validation->safe_name_in_url( $full_name );
//die( print_r( $full_name ) );
/* duplicate or not */
if ( $ultimatemember->user->user_has_metadata( 'full_name', $full_name ) ) {
+15 -1
View File
@@ -1,5 +1,19 @@
<?php
/***
*** @Main tabs
***/
add_filter('um_profile_tabs', 'um_profile_tabs', 1 );
function um_profile_tabs( $tabs ) {
$tabs['main'] = array(
'name' => __('About','ultimatemember'),
'icon' => 'um-faicon-user'
);
return $tabs;
}
/***
*** @dynamic profile page title
***/
@@ -42,5 +56,5 @@
}
}
return utf8_decode( $title );
return (strlen($title)!==strlen(utf8_decode($title))) ? $title : utf8_encode($title);
}
+1 -1
View File
@@ -131,7 +131,7 @@ class UM_Permalinks {
$profile_url = get_permalink($profile_url);
if ( um_get_option('permalink_base') == 'user_login' ) {
$user_in_url = $ultimatemember->user->profile['user_login'];
$user_in_url = um_user('user_login');
}
if ( um_get_option('permalink_base') == 'user_id' ) {
+29
View File
@@ -4,8 +4,37 @@ class UM_Profile {
function __construct() {
add_action('template_redirect', array(&$this, 'active_tab'), 10002);
$this->active_tab = 'main';
}
/***
*** @Global tabs
***/
function tabs(){
return apply_filters('um_profile_tabs', $tabs = array() );
}
/***
*** @Get active tab
***/
function active_tab() {
if ( get_query_var('profiletab') ) {
$this->active_tab = get_query_var('profiletab');
}
if ( get_query_var('subnav') ) {
$this->active_subnav = get_query_var('subnav');
}
}
/***
*** @Show meta in profile
***/
function show_meta( $array ) {
global $ultimatemember;
$output = '';
+20
View File
@@ -6,6 +6,26 @@ class UM_Query {
}
/***
*** @Do custom queries
***/
function make( $args ) {
$defaults = array(
'post_type' => 'post'
);
$args = wp_parse_args( $args, $defaults );
if ( isset( $args['post__in'] ) && empty( $args['post__in'] ) )
return false;
extract( $args );
$custom_posts = new WP_Query();
$custom_posts->query( $args );
return $custom_posts;
}
/***
*** @Get last users
***/
+2
View File
@@ -18,6 +18,8 @@ class UM_Rewrite {
function query_vars($public_query_vars) {
$public_query_vars[] = 'um_user';
$public_query_vars[] = 'um_tab';
$public_query_vars[] = 'profiletab';
$public_query_vars[] = 'subnav';
$public_query_vars[] = 'members_page';
return $public_query_vars;
}
+15 -10
View File
@@ -376,7 +376,8 @@
***/
function um_edit_my_profile_uri() {
global $ultimatemember;
$url = $ultimatemember->permalinks->add_query( 'um_action', 'edit' );
$url = $ultimatemember->permalinks->get_current_url(true);
$url = add_query_arg( 'um_action', 'edit', $url );
return $url;
}
@@ -384,8 +385,7 @@
*** @remove edit profile args from url
***/
function um_edit_my_profile_cancel_uri() {
global $ultimatemember;
$url = $ultimatemember->permalinks->remove_query( 'um_action', 'edit' );
$url = remove_query_arg( 'um_action' );
return $url;
}
@@ -504,25 +504,30 @@
global $ultimatemember;
if ( !is_user_logged_in() ) return false;
$return = 1;
um_fetch_user( get_current_user_id() );
switch($cap) {
case 'edit':
if ( get_current_user_id() == $user_id && um_user('can_edit_profile') ) return true;
if ( !um_user('can_edit_everyone') ) return false;
if ( get_current_user_id() == $user_id && !um_user('can_edit_profile') ) return false;
if ( um_user('can_edit_roles') && !in_array( $ultimatemember->query->get_role_by_userid( $user_id ), um_user('can_edit_roles') ) ) return false;
if ( get_current_user_id() == $user_id && um_user('can_edit_profile') ) $return = 1;
if ( !um_user('can_edit_everyone') ) $return = 0;
if ( get_current_user_id() == $user_id && !um_user('can_edit_profile') ) $return = 0;
if ( um_user('can_edit_roles') && !in_array( $ultimatemember->query->get_role_by_userid( $user_id ), um_user('can_edit_roles') ) ) $return = 0;
break;
case 'delete':
if ( !um_user('can_delete_everyone') ) return false;
if ( um_user('can_delete_roles') && !in_array( $ultimatemember->query->get_role_by_userid( $user_id ), um_user('can_delete_roles') ) ) return false;
if ( !um_user('can_delete_everyone') ) $return = 0;
if ( um_user('can_delete_roles') && !in_array( $ultimatemember->query->get_role_by_userid( $user_id ), um_user('can_delete_roles') ) ) $return = 0;
break;
}
return true;
um_fetch_user( $user_id );
return $return;
}
/***
+1
View File
@@ -457,6 +457,7 @@ class UM_User {
}
// hook for name changes
do_action('um_update_profile_full_name', $changes );
// update user