mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fixed bbPress restrict content message on forums;
- fixed issues with permalinks (issue #375); - fixed replacing placeholders in [show_content_for_role] shortcode;
This commit is contained in:
@@ -9,6 +9,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
|
||||
|
||||
var $settings_structure;
|
||||
var $previous_licenses;
|
||||
var $need_change_permalinks;
|
||||
|
||||
function __construct() {
|
||||
//init settings structure
|
||||
@@ -37,6 +38,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
|
||||
add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 );
|
||||
|
||||
//save pages options
|
||||
add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) );
|
||||
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
||||
|
||||
|
||||
@@ -1284,9 +1286,18 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
|
||||
}
|
||||
|
||||
|
||||
function check_permalinks_changes() {
|
||||
if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
||||
if ( UM()->options()->get( 'permalink_base' ) != $_POST['um_options']['permalink_base'] ) {
|
||||
$this->need_change_permalinks = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function on_settings_save() {
|
||||
if ( ! empty( $_POST['um_options'] ) ) {
|
||||
if ( ! empty( $_POST['pages_settings'] ) ) {
|
||||
if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
|
||||
$post_ids = new \WP_Query( array(
|
||||
'post_type' => 'page',
|
||||
'meta_query' => array(
|
||||
@@ -1311,6 +1322,17 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
|
||||
$slug = str_replace( 'core_', '', $option_slug );
|
||||
update_post_meta( $post_id, '_um_core', $slug );
|
||||
}
|
||||
} elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
||||
if ( ! empty( $this->need_change_permalinks ) ) {
|
||||
$users = get_users( array(
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
if ( ! empty( $users ) ) {
|
||||
foreach ( $users as $user_id ) {
|
||||
UM()->user()->generate_profile_slug( $user_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ if ( ! class_exists( 'Admin_Users' ) ) {
|
||||
function user_row_actions( $actions, $user_object ) {
|
||||
$user_id = $user_object->ID;
|
||||
|
||||
$actions['frontend_profile'] = "<a class='' href='" . UM()->user()->get_profile_url( $user_id ) . "'>" . __( 'View profile', 'ultimate-member' ) . "</a>";
|
||||
$actions['frontend_profile'] = "<a class='' href='" . UM()->user()->get_profile_link( $user_id ) . "'>" . __( 'View profile', 'ultimate-member' ) . "</a>";
|
||||
|
||||
$submitted = get_user_meta( $user_id, 'submitted', true );
|
||||
if ( ! empty( $submitted ) )
|
||||
|
||||
@@ -522,6 +522,11 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
}
|
||||
|
||||
$this->current_single_post = $post;
|
||||
add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
|
||||
|
||||
do_action( 'um_access_fix_external_post_content' );
|
||||
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
|
||||
@@ -613,6 +618,8 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'um_access_fix_external_post_content' );
|
||||
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
|
||||
@@ -663,17 +670,25 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = stripslashes( $restricted_global_message );
|
||||
|
||||
if ( 'attachment' == $post->post_type ) {
|
||||
$this->current_single_post = $post;
|
||||
add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
|
||||
|
||||
if ( 'attachment' == $post->post_type ) {
|
||||
remove_filter( 'the_content', 'prepend_attachment' );
|
||||
}
|
||||
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
||||
$post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
||||
|
||||
if ( 'attachment' == $post->post_type ) {
|
||||
$this->current_single_post = $post;
|
||||
add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
|
||||
|
||||
if ( 'attachment' == $post->post_type ) {
|
||||
remove_filter( 'the_content', 'prepend_attachment' );
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'um_access_fix_external_post_content' );
|
||||
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
|
||||
|
||||
@@ -20,7 +20,15 @@ if ( ! class_exists( 'External_Integrations' ) ) {
|
||||
add_filter( 'um_email_templates_columns', array( &$this , 'add_email_templates_wpml_column' ), 10, 1 );
|
||||
|
||||
|
||||
add_action( 'um_access_fix_external_post_content', array( &$this , 'bbpress_no_access_message_fix' ), 10 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fixed bbPress access to Forums message
|
||||
*/
|
||||
function bbpress_no_access_message_fix() {
|
||||
remove_filter( 'template_include', 'bbp_template_include' );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,13 +17,11 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
|
||||
add_action( 'init', array( &$this, 'activate_account_via_email_link' ), 1 );
|
||||
|
||||
add_action( 'um_user_after_updating_profile', array( &$this, 'profile_url' ), 1 );
|
||||
//add_action( 'um_user_after_updating_profile', array( &$this, 'profile_url' ), 1 );
|
||||
|
||||
remove_action( 'wp_head', 'rel_canonical' );
|
||||
|
||||
add_action( 'wp_head', array( &$this, 'um_rel_canonical_' ), 9 );
|
||||
|
||||
add_filter( 'um_user_pre_updating_profile_array', array( &$this, 'um_user_updating_profile_need_change_permalink' ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -236,6 +234,8 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
$this->current_url = add_query_arg( $key, $value, $this->get_current_url() );
|
||||
return $this->current_url;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @remove a query param from url
|
||||
***/
|
||||
@@ -244,116 +244,36 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
return $this->current_url;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @get profile url for set user
|
||||
***/
|
||||
function profile_url( $update_slug = false ) {
|
||||
// Permalink base
|
||||
$permalink_base = UM()->options()->get( 'permalink_base' );
|
||||
|
||||
/**
|
||||
* @param $slug
|
||||
*
|
||||
* @return int|null|string
|
||||
*/
|
||||
function slug_exists_user_id( $slug ) {
|
||||
global $wpdb;
|
||||
|
||||
// Get user slug
|
||||
$profile_slug = get_user_meta( um_user('ID'), "um_user_profile_url_slug_{$permalink_base}", true );
|
||||
$generate_slug = UM()->options()->get( 'um_generate_slug_in_directory' );
|
||||
$permalink_base = UM()->options()->get( 'permalink_base' );
|
||||
|
||||
// Return existing profile slug
|
||||
if( $generate_slug && $update_slug == false && $profile_slug ){
|
||||
return $this->profile_permalink( $profile_slug );
|
||||
}
|
||||
$user_id = $wpdb->get_var(
|
||||
"SELECT user_id
|
||||
FROM {$wpdb->usermeta}
|
||||
WHERE meta_key = 'um_user_profile_url_slug_{$permalink_base}' AND
|
||||
meta_value = '{$slug}'
|
||||
ORDER BY umeta_id ASC
|
||||
LIMIT 1"
|
||||
);
|
||||
|
||||
// Reset cache
|
||||
if( $update_slug == true ){
|
||||
if ( ! empty( $user_id ) ) {
|
||||
return $user_id;
|
||||
}
|
||||
|
||||
$user_id = um_user('ID');
|
||||
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
}
|
||||
|
||||
// Username
|
||||
if ( $permalink_base == 'user_login' ) {
|
||||
$user_in_url = um_user('user_login');
|
||||
|
||||
if ( is_email( $user_in_url ) ) {
|
||||
$user_email = $user_in_url;
|
||||
$user_in_url = str_replace('@','',$user_in_url);
|
||||
|
||||
if( ( $pos = strrpos( $user_in_url , '.' ) ) !== false ) {
|
||||
$search_length = strlen( '.' );
|
||||
$user_in_url = substr_replace( $user_in_url , '-' , $pos , $search_length );
|
||||
}
|
||||
update_user_meta( um_user('ID') , "um_email_as_username_{$user_in_url}" , $user_email );
|
||||
|
||||
} else {
|
||||
|
||||
$user_in_url = sanitize_title( $user_in_url );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// User ID
|
||||
if ( $permalink_base == 'user_id' ) {
|
||||
$user_in_url = um_user('ID');
|
||||
}
|
||||
|
||||
// Fisrt and Last name
|
||||
$full_name_permalinks = array( 'name', 'name_dash', 'name_plus' );
|
||||
|
||||
if ( in_array( $permalink_base, $full_name_permalinks ) ) {
|
||||
$separated = array( 'name' => '.', 'name_dash' => '-', 'name_plus'=> '+' );
|
||||
$separate = $separated[ $permalink_base ];
|
||||
$first_name = um_user( 'first_name' );
|
||||
$last_name = um_user( 'last_name' );
|
||||
$full_name = trim( sprintf('%s %s', $first_name, $last_name ) );
|
||||
$full_name = preg_replace( '/\s+/', ' ', $full_name ); // Remove double spaces
|
||||
$profile_slug = UM()->permalinks()->profile_slug( $full_name, $first_name, $last_name );
|
||||
|
||||
if ( isset($update_slug['need_change_permalink']) && $update_slug['need_change_permalink'] == true ) {
|
||||
|
||||
$append = 0;
|
||||
$username = $full_name;
|
||||
$_username = $full_name;
|
||||
|
||||
while ( 1 ) {
|
||||
$username = $_username . ( empty( $append ) ? '' : " $append" );
|
||||
if ( ! $this->exist_url_slug_permalink_base( $permalink_base, $profile_slug . ( empty( $append ) ? '' : "{$separate}{$append}" ) ) ) {
|
||||
break;
|
||||
}
|
||||
$append ++;
|
||||
|
||||
}
|
||||
|
||||
$user_in_url = $this->profile_slug( $username, $first_name, $last_name );
|
||||
if( empty( $user_in_url ) ) {
|
||||
$user_in_url = um_user('user_login');
|
||||
}
|
||||
$user_in_url = trim( $user_in_url, $separate );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update_user_meta( um_user('ID'), "um_user_profile_url_slug_{$permalink_base}", $user_in_url );
|
||||
$profile_url = $this->profile_permalink( $user_in_url );
|
||||
|
||||
return $profile_url;
|
||||
}
|
||||
|
||||
|
||||
function exist_url_slug_permalink_base( $permalink_base, $slug ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( $user_id = $wpdb->get_var( "SELECT `user_id` FROM `{$wpdb->usermeta}` WHERE `meta_key` = 'um_user_profile_url_slug_{$permalink_base}' AND `meta_value` = '{$slug}'" ) ) {
|
||||
return $user_id;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Profile Permalink
|
||||
*
|
||||
* @param string $slug
|
||||
* @return string $profile_url
|
||||
*/
|
||||
@@ -362,7 +282,7 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
$page_id = UM()->config()->permalinks['user'];
|
||||
$profile_url = get_permalink( $page_id );
|
||||
|
||||
$profile_url = apply_filters('um_localize_permalink_filter', UM()->config()->permalinks, $page_id, $profile_url );
|
||||
$profile_url = apply_filters( 'um_localize_permalink_filter', $profile_url, $page_id );
|
||||
|
||||
if ( get_option('permalink_structure') ) {
|
||||
|
||||
@@ -381,6 +301,7 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
|
||||
/**
|
||||
* Generate profile slug
|
||||
*
|
||||
* @param string $full_name
|
||||
* @param string $first_name
|
||||
* @param string $last_name
|
||||
@@ -509,22 +430,5 @@ if ( ! class_exists( 'Permalinks' ) ) {
|
||||
$url = add_query_arg( 'user_id', um_user('ID'), $url );
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the "need_change_permalink" parameter to recreate the user's permanent link*
|
||||
*
|
||||
* @param array $to_update
|
||||
* @return array $to_update
|
||||
*/
|
||||
function um_user_updating_profile_need_change_permalink( $to_update ) {
|
||||
|
||||
if ( um_user( 'first_name' ) != $to_update['first_name'] ||
|
||||
um_user( 'last_name' ) != $to_update['last_name'] ) {
|
||||
$to_update['need_change_permalink'] = true;
|
||||
}
|
||||
|
||||
return $to_update;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -665,20 +665,20 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
$current_user_roles = um_user( 'roles' );
|
||||
|
||||
if ( ! empty( $a['not'] ) && ! empty( $a['roles'] ) ) {
|
||||
return do_shortcode( $content );
|
||||
return do_shortcode( $this->convert_locker_tags( $content ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $a['not'] ) ) {
|
||||
$not_in_roles = explode( ",", $a['not'] );
|
||||
|
||||
if ( is_array( $not_in_roles ) && count( array_intersect( $current_user_roles, $not_in_roles ) ) <= 0 ) {
|
||||
return do_shortcode( $content );
|
||||
return do_shortcode( $this->convert_locker_tags( $content ) );
|
||||
}
|
||||
} else {
|
||||
$roles = explode( ",", $a['roles'] );
|
||||
|
||||
if ( is_array( $roles ) && count( array_intersect( $current_user_roles, $roles ) ) > 0 ) {
|
||||
return do_shortcode( $content );
|
||||
return do_shortcode( $this->convert_locker_tags( $content ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,37 +167,67 @@ if ( ! class_exists( 'User' ) ) {
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param bool $update_slug
|
||||
*
|
||||
* @return string
|
||||
* @return bool|mixed
|
||||
*/
|
||||
function get_profile_url( $user_id, $update_slug = false ) {
|
||||
function get_profile_slug( $user_id ) {
|
||||
// Permalink base
|
||||
$permalink_base = UM()->options()->get( 'permalink_base' );
|
||||
|
||||
// Get user slug
|
||||
$profile_slug = get_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", true );
|
||||
$generate_slug = UM()->options()->get( 'um_generate_slug_in_directory' );
|
||||
|
||||
// Return existing profile slug
|
||||
if ( $generate_slug && $update_slug == false && $profile_slug ) {
|
||||
return UM()->permalinks()->profile_permalink( $profile_slug );
|
||||
//get default username permalink if it's empty then return false
|
||||
if ( empty( $profile_slug ) ) {
|
||||
if ( $permalink_base != 'user_login' ) {
|
||||
$profile_slug = get_user_meta( $user_id, "um_user_profile_url_slug_user_login", true );
|
||||
}
|
||||
|
||||
if ( empty( $profile_slug ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $profile_slug;
|
||||
}
|
||||
|
||||
// Reset cache
|
||||
if ( $update_slug == true ) {
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
function get_profile_link( $user_id ) {
|
||||
$profile_slug = $this->get_profile_slug( $user_id );
|
||||
|
||||
if ( empty( $profile_slug ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return UM()->permalinks()->profile_permalink( $profile_slug );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
*/
|
||||
function generate_profile_slug( $user_id, $force = false ) {
|
||||
$userdata = get_userdata( $user_id );
|
||||
|
||||
if ( empty( $userdata ) ) {
|
||||
return UM()->permalinks()->profile_permalink( $profile_slug );
|
||||
return;
|
||||
}
|
||||
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
|
||||
$current_profile_slug = $this->get_profile_slug( $user_id );
|
||||
|
||||
$user_in_url = '';
|
||||
$permalink_base = UM()->options()->get( 'permalink_base' );
|
||||
|
||||
// User ID
|
||||
if ( $permalink_base == 'user_id' ) {
|
||||
$user_in_url = $user_id;
|
||||
}
|
||||
|
||||
// Username
|
||||
if ( $permalink_base == 'user_login' ) {
|
||||
|
||||
@@ -221,11 +251,6 @@ if ( ! class_exists( 'User' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
// User ID
|
||||
if ( $permalink_base == 'user_id' ) {
|
||||
$user_in_url = $user_id;
|
||||
}
|
||||
|
||||
// Fisrt and Last name
|
||||
$full_name_permalinks = array( 'name', 'name_dash', 'name_plus' );
|
||||
if ( in_array( $permalink_base, $full_name_permalinks ) ) {
|
||||
@@ -234,43 +259,50 @@ if ( ! class_exists( 'User' ) ) {
|
||||
$first_name = $userdata->first_name;
|
||||
$last_name = $userdata->last_name;
|
||||
$full_name = trim( sprintf( '%s %s', $first_name, $last_name ) );
|
||||
|
||||
$full_name = preg_replace( '/\s+/', ' ', $full_name ); // Remove double spaces
|
||||
|
||||
$profile_slug = UM()->permalinks()->profile_slug( $full_name, $first_name, $last_name );
|
||||
|
||||
$current_slug = get_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", true );
|
||||
if ( $current_slug ) {
|
||||
$username = $current_slug;
|
||||
} else {
|
||||
$append = 0;
|
||||
$username = $full_name;
|
||||
$_username = $full_name;
|
||||
|
||||
$append = 0;
|
||||
$username = $full_name;
|
||||
$_username = $full_name;
|
||||
|
||||
while ( 1 ) {
|
||||
$username = $_username . ( empty( $append ) ? '': " $append" );
|
||||
if ( ! UM()->permalinks()->exist_url_slug_permalink_base( $permalink_base, $profile_slug . ( empty( $append ) ? '' : "{$separate}{$append}" ) ) ) {
|
||||
break;
|
||||
}
|
||||
$append++;
|
||||
while ( 1 ) {
|
||||
$username = $_username . ( empty( $append ) ? '' : " $append" );
|
||||
$slug_exists_user_id = UM()->permalinks()->slug_exists_user_id( $profile_slug . ( empty( $append ) ? '' : "{$separate}{$append}" ) );
|
||||
if ( empty( $slug_exists_user_id ) || $user_id == $slug_exists_user_id ) {
|
||||
break;
|
||||
}
|
||||
$append++;
|
||||
}
|
||||
|
||||
$user_in_url = UM()->permalinks()->profile_slug( $username, $first_name, $last_name );
|
||||
if( empty( $user_in_url ) ) {
|
||||
if ( empty( $user_in_url ) ) {
|
||||
$user_in_url = $userdata->user_login;
|
||||
}
|
||||
|
||||
if ( is_email( $user_in_url ) ) {
|
||||
|
||||
$user_email = $user_in_url;
|
||||
$user_in_url = str_replace( '@', '', $user_in_url );
|
||||
|
||||
if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
|
||||
$search_length = strlen( '.' );
|
||||
$user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
|
||||
}
|
||||
update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
|
||||
|
||||
} else {
|
||||
|
||||
$user_in_url = sanitize_title( $user_in_url );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$user_in_url = trim( $user_in_url, $separate );
|
||||
}
|
||||
|
||||
update_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", $user_in_url );
|
||||
|
||||
if ( empty ( $user_in_url ) ) {
|
||||
$user_in_url = $user_id;
|
||||
if ( $force || empty( $current_profile_slug ) || $current_profile_slug != $user_in_url ) {
|
||||
update_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", $user_in_url );
|
||||
}
|
||||
|
||||
return UM()->permalinks()->profile_permalink( $user_in_url );
|
||||
}
|
||||
|
||||
|
||||
@@ -325,13 +357,7 @@ if ( ! class_exists( 'User' ) ) {
|
||||
do_action( 'um_after_member_role_upgrade', $new_roles, $old_roles );
|
||||
|
||||
//Update permalink
|
||||
$changes = apply_filters( 'um_user_edit_after_updating_profile_array', $_POST );
|
||||
if ( isset( $changes['need_change_permalink'] ) && $changes['need_change_permalink'] == true ) {
|
||||
$pre_user_id = um_user( 'ID' );
|
||||
um_fetch_user( $user_id );
|
||||
UM()->permalinks()->profile_url( $changes );
|
||||
um_fetch_user( $pre_user_id );
|
||||
}
|
||||
$this->generate_profile_slug( $user_id, true );
|
||||
|
||||
$this->remove_cache( $user_id );
|
||||
}
|
||||
|
||||
@@ -184,31 +184,9 @@ function um_submit_account_errors_hook( $args ) {
|
||||
unset( $changes['hide_in_members'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_account_pre_updating_profile_array
|
||||
* @description Contains all data from which are transmitted when updating information page "account". This filter is used before changing data in the database
|
||||
* @inpust_vars {
|
||||
* "(array) $changes": 'Contains all data from which are transmitted when updating information page "account"'
|
||||
* }
|
||||
*
|
||||
* @example
|
||||
* add_filter( 'um_account_pre_updating_profile_array', 'um_account_pre_updating_profile_need_change_permalink' );
|
||||
* function um_account_pre_updating_profile_need_change_permalink( $to_update ) {
|
||||
*
|
||||
* if ( um_user( 'first_name' ) != $to_update['first_name'] ||
|
||||
* um_user( 'last_name' ) != $to_update['last_name'] ) {
|
||||
* $to_update['need_change_permalink'] = true;
|
||||
* }
|
||||
*
|
||||
* return $to_update;
|
||||
* }
|
||||
*/
|
||||
$changes = apply_filters( 'um_account_pre_updating_profile_array', $changes );
|
||||
|
||||
// fired on account page, just before updating profile
|
||||
// fired on account page, just before updating profile
|
||||
do_action('um_account_pre_update_profile', $changes, um_user('ID') );
|
||||
|
||||
UM()->user()->update_profile( $changes );
|
||||
@@ -287,25 +265,6 @@ function um_submit_account_errors_hook( $args ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the "need_change_permalink" parameter to recreate the user's permanent link
|
||||
*
|
||||
* @param array $to_update
|
||||
* @return array $to_update
|
||||
*/
|
||||
function um_account_pre_updating_profile_need_change_permalink( $to_update ) {
|
||||
|
||||
if ( um_user( 'first_name' ) != $to_update['first_name'] ||
|
||||
um_user( 'last_name' ) != $to_update['last_name'] ) {
|
||||
$to_update['need_change_permalink'] = true;
|
||||
}
|
||||
|
||||
return $to_update;
|
||||
}
|
||||
|
||||
add_filter( 'um_account_pre_updating_profile_array', 'um_account_pre_updating_profile_need_change_permalink' );
|
||||
|
||||
|
||||
/**
|
||||
* Update Profile URL
|
||||
*
|
||||
@@ -313,6 +272,6 @@ add_filter( 'um_account_pre_updating_profile_array', 'um_account_pre_updating_pr
|
||||
* @param $changed
|
||||
*/
|
||||
function um_after_user_account_updated_permalink( $user_id, $changed ) {
|
||||
UM()->permalinks()->profile_url( $changed );
|
||||
UM()->user()->generate_profile_slug( $user_id );
|
||||
}
|
||||
add_action( 'um_after_user_account_updated', 'um_after_user_account_updated_permalink', 10, 2 );
|
||||
|
||||
@@ -138,10 +138,10 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
do_action( 'um_user_after_updating_profile', $to_update );
|
||||
|
||||
do_action( 'um_update_profile_full_name', $to_update );
|
||||
do_action( 'um_update_profile_full_name', um_user( 'ID' ), $to_update );
|
||||
|
||||
if (!isset( $args['is_signup'] )) {
|
||||
$url = UM()->user()->get_profile_url( um_user( 'ID' ), true );
|
||||
if ( ! isset( $args['is_signup'] ) ) {
|
||||
$url = UM()->user()->get_profile_link( um_user( 'ID' ) );
|
||||
exit( wp_redirect( um_edit_my_profile_cancel_uri( $url ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( $status == 'approved' ) {
|
||||
|
||||
UM()->user()->auto_login( $user_id );
|
||||
UM()->user()->get_profile_url( $user_id, true );
|
||||
UM()->user()->generate_profile_slug( $user_id );
|
||||
|
||||
do_action( 'um_registration_after_auto_login', $user_id );
|
||||
|
||||
@@ -350,7 +350,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
* @param $args
|
||||
*/
|
||||
function um_registration_set_profile_full_name( $user_id, $args ) {
|
||||
do_action( 'um_update_profile_full_name', $args );
|
||||
do_action( 'um_update_profile_full_name', $user_id, $args );
|
||||
}
|
||||
|
||||
add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_name', 10, 2 );
|
||||
@@ -6,14 +6,12 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
/***
|
||||
*** @profile name update
|
||||
***/
|
||||
add_action( 'um_update_profile_full_name', 'um_update_profile_full_name' );
|
||||
function um_update_profile_full_name( $changes ) {
|
||||
add_action( 'um_update_profile_full_name', 'um_update_profile_full_name', 10, 2 );
|
||||
function um_update_profile_full_name( $user_id, $changes ) {
|
||||
// Sync display name changes
|
||||
$option = UM()->options()->get( 'display_name' );
|
||||
|
||||
$user_id = UM()->user()->id;
|
||||
|
||||
if( ! isset( $user_id ) || empty( $user_id ) ){
|
||||
if ( ! isset( $user_id ) || empty( $user_id ) ) {
|
||||
$user = get_user_by( 'email', $changes['user_email'] );
|
||||
um_fetch_user( $user->ID );
|
||||
$user_id = $user->ID;
|
||||
@@ -68,6 +66,5 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
}
|
||||
|
||||
// regenerate slug
|
||||
UM()->user()->get_profile_url( $user_id, true );
|
||||
|
||||
UM()->user()->generate_profile_slug( $user_id );
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
add_filter("um_localize_permalink_filter","um_localize_permalink_filter",10,3);
|
||||
function um_localize_permalink_filter( $core_pages, $page_id, $profile_url ){
|
||||
add_filter( "um_localize_permalink_filter", "um_localize_permalink_filter", 10, 2 );
|
||||
function um_localize_permalink_filter( $profile_url, $page_id ) {
|
||||
|
||||
if ( function_exists('icl_get_current_language') && icl_get_current_language() != icl_get_default_language() ) {
|
||||
if ( get_the_ID() > 0 && get_post_meta( get_the_ID(), '_um_wpml_user', true ) == 1 ) {
|
||||
|
||||
@@ -186,34 +186,4 @@ function um_before_update_profile( $changes, $user_id ) {
|
||||
|
||||
return $changes;
|
||||
}
|
||||
add_filter( 'um_before_update_profile','um_before_update_profile', 10, 2 );
|
||||
|
||||
|
||||
/**
|
||||
* @param $meta
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function um_user_edit_check_change_first_name_and_last_name( $meta ) {
|
||||
if ( ! empty( $_POST['user_id'] ) ) {
|
||||
if ( get_user_meta( $_POST['user_id'], 'first_name', true ) != $meta['first_name'] ||
|
||||
get_user_meta( $_POST['user_id'], 'last_name', true ) != $meta['last_name'] ) {
|
||||
add_filter( 'um_user_edit_after_updating_profile_array', 'um_user_edit_after_updating_profile_need_change_permalink' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $meta;
|
||||
}
|
||||
add_filter( 'insert_user_meta','um_user_edit_check_change_first_name_and_last_name', 10, 1 );
|
||||
|
||||
|
||||
/**
|
||||
* @param $to_update
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function um_user_edit_after_updating_profile_need_change_permalink( $to_update ) {
|
||||
$to_update['need_change_permalink'] = true;
|
||||
return $to_update;
|
||||
}
|
||||
add_filter( 'um_before_update_profile','um_before_update_profile', 10, 2 );
|
||||
@@ -1169,7 +1169,7 @@ function um_admin_email() {
|
||||
* @return string
|
||||
*/
|
||||
function um_user_profile_url() {
|
||||
return UM()->user()->get_profile_url( um_user( 'ID' ) );
|
||||
return UM()->user()->get_profile_link( um_user( 'ID' ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user