mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- fixed roles priority and added functions to work with roles (all|priority|um role);
- fixed um_is_core_page function with WPML; - added general admin notice when user have old extensions; - text changes;
This commit is contained in:
@@ -1830,7 +1830,7 @@ Host: <?php echo $host . "\n"; ?>
|
||||
---- Current User Details --
|
||||
|
||||
<?php $user = wp_get_current_user(); ?>
|
||||
Role: <?php echo um_user( 'role' ). "\n"; ?>
|
||||
Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
|
||||
|
||||
|
||||
--- WordPress Configurations ---
|
||||
|
||||
@@ -157,36 +157,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
exit( wp_redirect( remove_query_arg('um_adm_action') ) );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Opt-in tracking
|
||||
***/
|
||||
add_action('um_admin_do_action__opt_into_tracking', 'um_admin_do_action__opt_into_tracking');
|
||||
function um_admin_do_action__opt_into_tracking( $action ) {
|
||||
if ( !is_admin() || !current_user_can('manage_options') ) die();
|
||||
|
||||
UM()->options()->update( 'um_allow_tracking', 1 );
|
||||
update_option( 'um_tracking_notice', 1 );
|
||||
|
||||
$tracking = new um\core\Tracking();
|
||||
$tracking->send_checkin(true);
|
||||
|
||||
exit( wp_redirect( remove_query_arg('um_adm_action') ) );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Opt-out of tracking
|
||||
***/
|
||||
add_action('um_admin_do_action__opt_out_of_tracking', 'um_admin_do_action__opt_out_of_tracking');
|
||||
function um_admin_do_action__opt_out_of_tracking( $action ){
|
||||
if ( !is_admin() || !current_user_can('manage_options') ) die();
|
||||
|
||||
UM()->options()->update( 'um_allow_tracking', 0 );
|
||||
update_option('um_tracking_notice', 1 );
|
||||
|
||||
exit( wp_redirect( remove_query_arg('um_adm_action') ) );
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @various user actions
|
||||
***/
|
||||
|
||||
@@ -57,6 +57,16 @@ if ( ! class_exists( 'um\Dependencies' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_active_plugins() {
|
||||
if ( ! self::$active_plugins ) self::init();
|
||||
|
||||
return self::$active_plugins;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if UltimateMember core plugin is active
|
||||
*
|
||||
|
||||
+16
-5
@@ -189,7 +189,7 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
// include hook files
|
||||
add_action( 'plugins_loaded', array( &$this, 'init' ), 0 );
|
||||
|
||||
//add_action( 'init', array( &$this, 'old_extensions_notice' ), 0 );
|
||||
add_action( 'init', array( &$this, 'old_extensions_notice' ), 0 );
|
||||
|
||||
//run activation
|
||||
register_activation_hook( um_plugin, array( &$this, 'activation' ) );
|
||||
@@ -205,8 +205,17 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
}
|
||||
|
||||
|
||||
function old_extensions_notice() {
|
||||
if ( ! is_admin() ) return;
|
||||
/**
|
||||
* Show notice for customers with old extension's versions
|
||||
*/
|
||||
function old_extensions_notice() {
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$show = false;
|
||||
|
||||
@@ -225,13 +234,15 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $show ) return;
|
||||
if ( ! $show ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*global $um_woocommerce;
|
||||
remove_action( 'init', array( $um_woocommerce, 'plugin_check' ), 1 );
|
||||
$um_woocommerce->plugin_inactive = true;*/
|
||||
|
||||
echo '<div class="error"><p>' . sprintf( __( '<strong>ATTENTION!</strong> You have pre-2.0 version activated <strong>%s</strong> extensions. Please install the latest versions.', 'ultimate-member' ), ultimatemember_plugin_name ) . '</p></div>';
|
||||
echo '<div class="error"><p>' . sprintf( __( '<strong>ATTENTION!</strong> %s %s requires 2.0 extensions. You have pre 2.0 extensions installed on your site. <br /> Please update %s extensions to latest versions. For more info see this <a href="%s" target="_blank">doc</a>.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'http://docs.ultimatemember.com/article/266-updating-to-2-0-versions-of-extensions' ) . '</p></div>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -189,12 +189,11 @@ if ( ! class_exists( 'Access' ) ) {
|
||||
if ( is_front_page() ) {
|
||||
if ( is_user_logged_in() ) {
|
||||
|
||||
$role_meta = UM()->roles()->role_data( um_user( 'role' ) );
|
||||
|
||||
if ( ! empty( $role_meta['default_homepage'] ) )
|
||||
if ( ! empty( um_user( 'default_homepage' ) ) )
|
||||
return;
|
||||
|
||||
$redirect_to = ! empty( $role_meta['redirect_homepage'] ) ? $role_meta['redirect_homepage'] : um_get_core_page( 'user' );
|
||||
$redirect_homepage = um_user( 'redirect_homepage' );
|
||||
$redirect_to = ! empty( $redirect_homepage ) ? $redirect_homepage : um_get_core_page( 'user' );
|
||||
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect_to ) ), "custom_homepage" );
|
||||
|
||||
} else {
|
||||
|
||||
@@ -1165,18 +1165,21 @@ if ( ! class_exists( 'Fields' ) ) {
|
||||
) {
|
||||
|
||||
um_fetch_user( get_current_user_id() );
|
||||
if (!um_user( 'can_edit_everyone' ))
|
||||
if ( ! um_user( 'can_edit_everyone' ) ) {
|
||||
$disabled = ' disabled="disabled" ';
|
||||
}
|
||||
|
||||
um_fetch_user( $_um_profile_id );
|
||||
if (isset( $data['public'] ) && $data['public'] == '-2' && $data['roles']) {
|
||||
if (in_array( UM()->roles()->um_get_user_role( get_current_user_id() ), $data['roles'] )) {
|
||||
if ( isset( $data['public'] ) && $data['public'] == '-2' && $data['roles'] ) {
|
||||
$current_user_roles = um_user( 'roles' );
|
||||
if ( count( array_intersect( $current_user_roles, $data['roles'] ) ) > 0 ) {
|
||||
$disabled = '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!isset( $data['autocomplete'] )) {
|
||||
if ( ! isset( $data['autocomplete'] ) ) {
|
||||
$autocomplete = 'off';
|
||||
}
|
||||
um_fetch_user( get_current_user_id() );
|
||||
|
||||
@@ -441,6 +441,7 @@ if ( ! class_exists( 'REST_API' ) ) {
|
||||
break;
|
||||
|
||||
case 'role':
|
||||
//get priority role here
|
||||
$response['role'] = um_user( 'role' );
|
||||
break;
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
// User exists
|
||||
if ( ! empty( $user ) ) {
|
||||
// Get users old UM role
|
||||
$role = $this->um_get_user_role( $user_id );
|
||||
$role = UM()->roles()->get_um_user_role( $user_id );
|
||||
|
||||
// User already has this role so no new role is set
|
||||
if ( $new_role === $role || ( ! $this->is_role_custom( $new_role ) && user_can( $user, $new_role ) ) ) {
|
||||
@@ -173,49 +173,106 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
/**
|
||||
* Get user one of UM roles if it has it
|
||||
*
|
||||
* @deprecated since 2.0
|
||||
* @param int $user_id
|
||||
* @return bool|mixed
|
||||
*/
|
||||
function um_get_user_role( $user_id ) {
|
||||
$user = get_userdata( $user_id );
|
||||
|
||||
if ( empty( $user->roles ) )
|
||||
return false;
|
||||
|
||||
// User has roles so look for a UM Role one
|
||||
$um_roles_keys = get_option( 'um_roles' );
|
||||
|
||||
if ( ! empty( $um_roles_keys ) ) {
|
||||
$um_roles_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, $um_roles_keys );
|
||||
}
|
||||
|
||||
$orders = array();
|
||||
foreach ( array_values( $user->roles ) as $userrole ) {
|
||||
if ( ! empty( $um_roles_keys ) && in_array( $userrole, $um_roles_keys ) ) {
|
||||
$userrole_metakey = substr( $userrole, 3 );
|
||||
} else {
|
||||
$userrole_metakey = $userrole;
|
||||
}
|
||||
|
||||
$rolemeta = get_option( "um_role_{$userrole_metakey}_meta", false );
|
||||
|
||||
if ( ! $rolemeta ) {
|
||||
$orders[ $userrole ] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
$orders[ $userrole ] = ! empty( $rolemeta['_um_priority'] ) ? $rolemeta['_um_priority'] : 0;
|
||||
}
|
||||
|
||||
arsort( $orders );
|
||||
$roles_in_priority = array_keys( $orders );
|
||||
|
||||
return array_shift( $roles_in_priority );
|
||||
return $this->get_um_user_role( $user_id );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
function get_all_user_roles( $user_id ) {
|
||||
$user = get_userdata( $user_id );
|
||||
|
||||
if ( empty( $user->roles ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_values( $user->roles );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
function get_priority_user_role( $user_id ) {
|
||||
$user = get_userdata( $user_id );
|
||||
|
||||
if ( empty( $user->roles ) )
|
||||
return false;
|
||||
|
||||
// User has roles so look for a UM Role one
|
||||
$um_roles_keys = get_option( 'um_roles' );
|
||||
|
||||
if ( ! empty( $um_roles_keys ) ) {
|
||||
$um_roles_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, $um_roles_keys );
|
||||
}
|
||||
|
||||
$orders = array();
|
||||
foreach ( array_values( $user->roles ) as $userrole ) {
|
||||
if ( ! empty( $um_roles_keys ) && in_array( $userrole, $um_roles_keys ) ) {
|
||||
$userrole_metakey = substr( $userrole, 3 );
|
||||
} else {
|
||||
$userrole_metakey = $userrole;
|
||||
}
|
||||
|
||||
$rolemeta = get_option( "um_role_{$userrole_metakey}_meta", false );
|
||||
|
||||
if ( ! $rolemeta ) {
|
||||
$orders[ $userrole ] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
$orders[ $userrole ] = ! empty( $rolemeta['_um_priority'] ) ? $rolemeta['_um_priority'] : 0;
|
||||
}
|
||||
|
||||
arsort( $orders );
|
||||
$roles_in_priority = array_keys( $orders );
|
||||
|
||||
return array_shift( $roles_in_priority );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
function get_um_user_role( $user_id ) {
|
||||
// User has roles so look for a UM Role one
|
||||
$um_roles_keys = get_option( 'um_roles' );
|
||||
|
||||
if ( empty( $um_roles_keys ) )
|
||||
return false;
|
||||
|
||||
$user = get_userdata( $user_id );
|
||||
|
||||
if ( empty( $user->roles ) )
|
||||
return false;
|
||||
|
||||
$um_roles_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, $um_roles_keys );
|
||||
|
||||
$user_um_roles_array = array_intersect( $um_roles_keys, array_values( $user->roles ) );
|
||||
|
||||
if ( empty( $user_um_roles_array ) )
|
||||
return false;
|
||||
|
||||
return array_shift( $user_um_roles_array );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get role name by roleID
|
||||
*
|
||||
@@ -264,9 +321,14 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Query for UM roles
|
||||
***/
|
||||
/**
|
||||
* Query for UM roles
|
||||
*
|
||||
* @param bool $add_default
|
||||
* @param null $exclude
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_roles( $add_default = false, $exclude = null ){
|
||||
global $wp_roles;
|
||||
|
||||
@@ -290,9 +352,14 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Current user can
|
||||
***/
|
||||
/**
|
||||
* Current user can
|
||||
*
|
||||
* @param $cap
|
||||
* @param $user_id
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
function um_current_user_can( $cap, $user_id ) {
|
||||
if ( ! is_user_logged_in() )
|
||||
return false;
|
||||
@@ -301,7 +368,8 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
|
||||
um_fetch_user( get_current_user_id() );
|
||||
|
||||
switch( $cap ) {
|
||||
$current_user_roles = UM()->roles()->get_all_user_roles( $user_id );
|
||||
switch( $cap ) {
|
||||
case 'edit':
|
||||
if ( get_current_user_id() == $user_id && um_user( 'can_edit_profile' ) )
|
||||
$return = 1;
|
||||
@@ -309,13 +377,15 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
$return = 0;
|
||||
elseif ( get_current_user_id() == $user_id && ! um_user( 'can_edit_profile') )
|
||||
$return = 0;
|
||||
elseif ( um_user( 'can_edit_roles' ) && ! in_array( UM()->roles()->um_get_user_role( $user_id ), um_user( 'can_edit_roles' ) ) )
|
||||
elseif ( um_user( 'can_edit_roles' ) && count( array_intersect( $current_user_roles, um_user( 'can_edit_roles' ) ) ) <= 0 )
|
||||
$return = 0;
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if ( ! um_user( 'can_delete_everyone' ) ) $return = 0;
|
||||
elseif ( um_user( 'can_delete_roles' ) && ! in_array( UM()->roles()->um_get_user_role( $user_id ), um_user( 'can_delete_roles' ) ) ) $return = 0;
|
||||
if ( ! um_user( 'can_delete_everyone' ) )
|
||||
$return = 0;
|
||||
elseif ( um_user( 'can_delete_roles' ) && count( array_intersect( $current_user_roles, um_user( 'can_delete_roles' ) ) ) <= 0 )
|
||||
$return = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -337,8 +407,7 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
return false;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$role = $this->um_get_user_role( $user_id );
|
||||
|
||||
$role = UM()->roles()->get_priority_user_role( $user_id );
|
||||
$permissions = $this->role_data( $role );
|
||||
$permissions = apply_filters( 'um_user_permissions_filter', $permissions, $user_id );
|
||||
|
||||
|
||||
@@ -381,9 +381,11 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
}
|
||||
|
||||
// for profiles only
|
||||
if ($mode == 'profile' && um_profile_id() && isset($args['role']) && $args['role'] &&
|
||||
$args['role'] != UM()->roles()->um_get_user_role( um_profile_id() ) ) {
|
||||
return;
|
||||
if ( $mode == 'profile' && um_profile_id() ) {
|
||||
$current_user_roles = UM()->roles()->get_all_user_roles( um_profile_id() );
|
||||
if ( ! empty( $args['role'] ) && ! in_array( $args['role'], $current_user_roles ) ) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
// start loading the template here
|
||||
@@ -627,72 +629,71 @@ if ( ! class_exists( 'Shortcodes' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shortcode: Show custom content to specific role
|
||||
*
|
||||
* Show content to specific roles
|
||||
* [um_show_content roles='member'] <!-- insert content here --> [/um_show_content]
|
||||
* You can add multiple target roles, just use ',' e.g. [um_show_content roles='member,candidates,pets']
|
||||
*
|
||||
* Hide content from specific roles
|
||||
* [um_show_content not='contributors'] <!-- insert content here --> [/um_show_content]
|
||||
* You can add multiple target roles, just use ',' e.g. [um_show_content roles='member,candidates,pets']
|
||||
*
|
||||
* @param array $atts
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
function um_shortcode_show_content_for_role( $atts = array() , $content = '' ) {
|
||||
/**
|
||||
* Shortcode: Show custom content to specific role
|
||||
*
|
||||
* Show content to specific roles
|
||||
* [um_show_content roles='member'] <!-- insert content here --> [/um_show_content]
|
||||
* You can add multiple target roles, just use ',' e.g. [um_show_content roles='member,candidates,pets']
|
||||
*
|
||||
* Hide content from specific roles
|
||||
* [um_show_content not='contributors'] <!-- insert content here --> [/um_show_content]
|
||||
* You can add multiple target roles, just use ',' e.g. [um_show_content roles='member,candidates,pets']
|
||||
*
|
||||
* @param array $atts
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
function um_shortcode_show_content_for_role( $atts = array() , $content = '' ) {
|
||||
global $user_ID;
|
||||
|
||||
global $user_ID;
|
||||
if ( ! is_user_logged_in() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! is_user_logged_in() ) {
|
||||
return;
|
||||
}
|
||||
$a = shortcode_atts( array(
|
||||
'roles' => '',
|
||||
'not' => '',
|
||||
'is_profile' => false,
|
||||
), $atts );
|
||||
|
||||
$a = shortcode_atts( array(
|
||||
'roles' => '',
|
||||
'not' => '',
|
||||
'is_profile' => false,
|
||||
), $atts );
|
||||
if ( $a['is_profile'] ) {
|
||||
um_fetch_user( um_profile_id() );
|
||||
} else {
|
||||
um_fetch_user( $user_ID );
|
||||
}
|
||||
|
||||
if( $a['is_profile'] ){
|
||||
um_fetch_user( um_profile_id() );
|
||||
}else{
|
||||
um_fetch_user( $user_ID );
|
||||
}
|
||||
$current_user_roles = um_user( 'roles' );
|
||||
|
||||
if ( ! empty( $a['not'] ) && ! empty( $a['roles'] ) ) {
|
||||
return do_shortcode( $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 );
|
||||
}
|
||||
} else {
|
||||
$roles = explode( ",", $a['roles'] );
|
||||
|
||||
if ( is_array( $roles ) && count( array_intersect( $current_user_roles, $roles ) ) > 0 ) {
|
||||
return do_shortcode( $content );
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$current_user_role = um_user( 'role' );
|
||||
|
||||
if( isset( $a['not'] ) && ! empty( $a['not'] ) && isset( $a['roles'] ) && ! empty( $a['roles'] ) ){
|
||||
return do_shortcode( $content );
|
||||
}
|
||||
|
||||
if( isset( $a['not'] ) && ! empty( $a['not'] ) ){
|
||||
|
||||
$not_in_roles = explode(",", $a['not'] );
|
||||
|
||||
if( is_array( $not_in_roles ) && ! in_array( $current_user_role, $not_in_roles ) ){
|
||||
return do_shortcode( $content );
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
$roles = explode(",", $a['roles'] );
|
||||
|
||||
if(is_array( $roles ) && in_array( $current_user_role, $roles ) ){
|
||||
return do_shortcode( $content );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function ultimatemember_searchform($args = array(), $content = "") {
|
||||
/**
|
||||
* @param array $args
|
||||
* @param string $content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ultimatemember_searchform( $args = array(), $content = "" ) {
|
||||
// turn off buffer
|
||||
ob_start();
|
||||
|
||||
|
||||
@@ -15,8 +15,34 @@ if ( ! class_exists( 'Tracking' ) ) {
|
||||
|
||||
add_action( 'admin_notices', array( $this, 'admin_notices' ), 10 );
|
||||
|
||||
add_action( 'um_admin_do_action__opt_into_tracking', array( $this, 'um_admin_do_action__opt_into_tracking' ) );
|
||||
add_action( 'um_admin_do_action__opt_out_of_tracking', array( $this, 'um_admin_do_action__opt_out_of_tracking' ) );
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Opt-in tracking
|
||||
***/
|
||||
function um_admin_do_action__opt_into_tracking( $action ) {
|
||||
UM()->options()->update( 'um_allow_tracking', 1 );
|
||||
update_option( 'um_tracking_notice', 1 );
|
||||
|
||||
$this->send_checkin(true);
|
||||
|
||||
exit( wp_redirect( remove_query_arg('um_adm_action') ) );
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Opt-out of tracking
|
||||
***/
|
||||
function um_admin_do_action__opt_out_of_tracking( $action ) {
|
||||
UM()->options()->update( 'um_allow_tracking', 0 );
|
||||
update_option('um_tracking_notice', 1 );
|
||||
|
||||
exit( wp_redirect( remove_query_arg('um_adm_action') ) );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @setup info array
|
||||
***/
|
||||
@@ -145,12 +171,12 @@ if ( ! class_exists( 'Tracking' ) ) {
|
||||
|
||||
echo '<div class="updated um-admin-notice"><p>';
|
||||
|
||||
echo __( 'Allow Ultimate Member to track plugin usage? Opt-in to tracking and our newsletter and we will immediately e-mail you a 20% discount which you can use to purchase our core extensions bundle. No sensitive data is tracked.', 'ultimate-member' );
|
||||
printf( __( 'Thanks for installing <strong>%s</strong>! The core plugin is free but we also sell extensions which allow us to continue developing and supporting the plugin full time. If you subscribe to our mailing list (no spam) we will email you a 20%% discount code which you can use to purchase the <a href="%s" target="_blank">extensions bundle</a>.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' );
|
||||
|
||||
echo '</p>';
|
||||
|
||||
echo '<p><a href="' . esc_url( $optin_url ) . '" class="button button-primary">' . __( 'Allow tracking', 'ultimate-member' ) . '</a>';
|
||||
echo ' <a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'Do not allow tracking', 'ultimate-member' ) . '</a></p></div>';
|
||||
echo '<p><a href="' . esc_url( $optin_url ) . '" class="button button-primary">' . __( 'Subscribe to mailing list', 'ultimate-member' ) . '</a>';
|
||||
echo ' <a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'No thanks', 'ultimate-member' ) . '</a></p></div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -384,7 +384,8 @@ if ( ! class_exists( 'User' ) ) {
|
||||
if ( ! current_user_can( 'edit_user', $userdata->ID ) )
|
||||
return $content;
|
||||
|
||||
$user_role = UM()->roles()->um_get_user_role( $userdata->ID );
|
||||
//$user_role = UM()->roles()->um_get_user_role( $userdata->ID );
|
||||
$user_role = UM()->roles()->get_um_user_role( $userdata->ID );
|
||||
if ( $user_role && ! empty( $userdata->roles ) && count( $userdata->roles ) == 1 )
|
||||
$style = 'style="display:none;"';
|
||||
|
||||
@@ -474,6 +475,7 @@ if ( ! class_exists( 'User' ) ) {
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @function set()
|
||||
*
|
||||
@@ -585,9 +587,11 @@ if ( ! class_exists( 'User' ) ) {
|
||||
}
|
||||
|
||||
// add permissions
|
||||
$user_role = UM()->roles()->um_get_user_role( $this->id );
|
||||
//$user_role = UM()->roles()->um_get_user_role( $this->id );
|
||||
$user_role = UM()->roles()->get_priority_user_role( $this->id );
|
||||
//$this->profile['role'] = ( strpos( $user_role, 'um_' ) === 0 ) ? str_replace( 'um_', '', $user_role ) : $user_role;
|
||||
$this->profile['role'] = $user_role;
|
||||
$this->profile['roles'] = UM()->roles()->get_all_user_roles( $this->id );
|
||||
|
||||
$role_meta = UM()->roles()->role_data( $user_role );
|
||||
$role_meta = apply_filters( 'um_user_permissions_filter', $role_meta, $this->id );
|
||||
|
||||
@@ -142,7 +142,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
foreach ( $fields as $key => $array ) {
|
||||
|
||||
if ( isset( $array['public'] ) && -2 == $array['public'] && ! empty( $array['roles'] ) && is_user_logged_in() ) {
|
||||
if ( ! in_array( um_user( 'role' ), $array['roles'] ) ) {
|
||||
$current_user_roles = um_user( 'roles' );
|
||||
if ( count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,11 +166,12 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
um_store_lastlogin_timestamp( $user->ID );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @login user
|
||||
***/
|
||||
add_action('um_user_login', 'um_user_login', 10);
|
||||
function um_user_login($args){
|
||||
/**
|
||||
* Login user process
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
function um_user_login( $args ) {
|
||||
extract( $args );
|
||||
|
||||
$rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
|
||||
@@ -179,30 +180,29 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
wp_die( __('This action has been prevented for security measures.','ultimate-member') );
|
||||
}
|
||||
|
||||
UM()->user()->auto_login( um_user('ID'), $rememberme );
|
||||
UM()->user()->auto_login( um_user( 'ID' ), $rememberme );
|
||||
|
||||
// Hook that runs after successful login and before user is redirected
|
||||
do_action('um_on_login_before_redirect', um_user('ID') );
|
||||
do_action( 'um_on_login_before_redirect', um_user( 'ID' ) );
|
||||
|
||||
// Priority redirect
|
||||
if ( isset( $args['redirect_to'] ) && ! empty( $args['redirect_to'] ) ) {
|
||||
exit( wp_redirect( $args['redirect_to'] ) );
|
||||
if ( ! empty( $args['redirect_to'] ) ) {
|
||||
exit( wp_redirect( $args['redirect_to'] ) );
|
||||
}
|
||||
|
||||
$role_data = UM()->roles()->role_data( um_user( 'role' ) );
|
||||
|
||||
// Role redirect
|
||||
if ( empty( $role_data['after_login'] ) )
|
||||
$after_login = um_user( 'after_login' );
|
||||
if ( empty( $after_login ) )
|
||||
exit( wp_redirect( um_user_profile_url() ) );
|
||||
|
||||
switch( $role_data['after_login'] ) {
|
||||
switch( $after_login ) {
|
||||
|
||||
case 'redirect_admin':
|
||||
exit( wp_redirect( admin_url() ) );
|
||||
break;
|
||||
|
||||
case 'redirect_url':
|
||||
exit( wp_redirect( $role_data['login_redirect_url'] ) );
|
||||
exit( wp_redirect( um_user( 'login_redirect_url' ) ) );
|
||||
break;
|
||||
|
||||
case 'refresh':
|
||||
@@ -216,6 +216,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'um_user_login', 'um_user_login', 10 );
|
||||
|
||||
|
||||
/***
|
||||
*** @form processing
|
||||
|
||||
@@ -19,17 +19,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
}
|
||||
|
||||
$search_filters = apply_filters('um_frontend_member_search_filters',$search_filters);
|
||||
|
||||
|
||||
if ( $args['search'] == 1 && is_array( $search_filters ) ) { // search on
|
||||
|
||||
if ( isset( $args['roles_can_search'] ) && ! empty( $args['roles_can_search'] ) && ! in_array( um_user( 'role' ), $args['roles_can_search'] ) ) {
|
||||
|
||||
$current_user_roles = um_user( 'roles' );
|
||||
if ( ! empty( $args['roles_can_search'] ) && count( array_intersect( $current_user_roles, $args['roles_can_search'] ) ) <= 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$count = count( $search_filters );
|
||||
|
||||
?>
|
||||
|
||||
$count = count( $search_filters ); ?>
|
||||
|
||||
<div class="um-search um-search-<?php echo $count; ?>">
|
||||
|
||||
<form method="get" action="" />
|
||||
|
||||
@@ -124,6 +124,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
$url = UM()->permalinks()->get_current_url();
|
||||
$url = add_query_arg( 'message', esc_attr( $status ), $url );
|
||||
//add only priority role to URL
|
||||
$url = add_query_arg( 'um_role', esc_attr( um_user( 'role' ) ), $url );
|
||||
$url = add_query_arg( 'um_form_id', esc_attr( $args['form_id'] ), $url );
|
||||
|
||||
|
||||
@@ -3,82 +3,53 @@
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
/***
|
||||
*** @sync with WP role
|
||||
***/
|
||||
add_action('um_after_user_role_is_updated','um_setup_synced_wp_role', 50, 2);
|
||||
function um_setup_synced_wp_role( $user_id, $role ) {
|
||||
$meta = UM()->roles()->role_data( $role );
|
||||
$meta = apply_filters('um_user_permissions_filter', $meta, $user_id );
|
||||
$wp_user_object = new WP_User( $user_id );
|
||||
|
||||
if ( isset( $meta['synced_role'] ) && $meta['synced_role'] ) {
|
||||
$wp_user_object->add_role( $meta['synced_role'] );
|
||||
}elseif( ! $wp_user_object->roles ) { // Fallback user default role if nothing set
|
||||
$wp_user_object->add_role( 'subscriber' );
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
*** @remove previously synced WP role
|
||||
***/
|
||||
add_action('um_when_role_is_set', 'um_remove_prev_synced_wp_role');
|
||||
function um_remove_prev_synced_wp_role( $user_id ) {
|
||||
um_fetch_user( $user_id );
|
||||
$meta = UM()->roles()->role_data( um_user( 'role' ) );
|
||||
if ( isset( $meta['synced_role'] ) && $meta['synced_role'] ) {
|
||||
$wp_user_object = new WP_User( $user_id );
|
||||
$wp_user_object->remove_role( $meta['synced_role'] );
|
||||
}
|
||||
/**
|
||||
* Clean user temp uploads
|
||||
*
|
||||
* @param $user_id
|
||||
* @param $post_array
|
||||
*/
|
||||
function um_remove_unused_uploads( $user_id, $post_array ) {
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
$user_meta_keys = UM()->user()->profile;
|
||||
|
||||
$_array = array();
|
||||
foreach ( UM()->builtin()->custom_fields as $_field ) {
|
||||
if ( $_field['type'] == 'file' && ! empty( $user_meta_keys[ $_field['metakey'] ] ) )
|
||||
$_array[] = $user_meta_keys[ $_field['metakey'] ];
|
||||
}
|
||||
$_array = array_merge( $_array, $post_array );
|
||||
|
||||
|
||||
/**
|
||||
* Clean user temp uploads
|
||||
*
|
||||
* @param $user_id
|
||||
* @param $post_array
|
||||
*/
|
||||
function um_remove_unused_uploads( $user_id, $post_array ) {
|
||||
um_fetch_user( $user_id );
|
||||
$files = glob( um_user_uploads_dir() . '*', GLOB_BRACE );
|
||||
$error = array();
|
||||
if ( file_exists( um_user_uploads_dir() ) && $files && isset( $_array ) && is_array( $_array ) ) {
|
||||
foreach ( $files as $file ) {
|
||||
$str = basename( $file );
|
||||
|
||||
$user_meta_keys = UM()->user()->profile;
|
||||
|
||||
$_array = array();
|
||||
foreach ( UM()->builtin()->custom_fields as $_field ) {
|
||||
if ( $_field['type'] == 'file' && ! empty( $user_meta_keys[ $_field['metakey'] ] ) )
|
||||
$_array[] = $user_meta_keys[ $_field['metakey'] ];
|
||||
}
|
||||
$_array = array_merge( $_array, $post_array );
|
||||
|
||||
|
||||
$files = glob( um_user_uploads_dir() . '*', GLOB_BRACE );
|
||||
$error = array();
|
||||
if ( file_exists( um_user_uploads_dir() ) && $files && isset( $_array ) && is_array( $_array ) ) {
|
||||
foreach ( $files as $file ) {
|
||||
$str = basename( $file );
|
||||
|
||||
if ( ! strstr( $str, 'profile_photo' ) && ! strstr( $str, 'cover_photo' ) &&
|
||||
! strstr( $str, 'stream_photo' ) && ! preg_grep( '/' . $str . '/', $_array ) ) {
|
||||
$error[] = $str;
|
||||
unlink( $file );
|
||||
}
|
||||
if ( ! strstr( $str, 'profile_photo' ) && ! strstr( $str, 'cover_photo' ) &&
|
||||
! strstr( $str, 'stream_photo' ) && ! preg_grep( '/' . $str . '/', $_array ) ) {
|
||||
$error[] = $str;
|
||||
unlink( $file );
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'um_after_user_upload','um_remove_unused_uploads', 10, 2 );
|
||||
}
|
||||
add_action( 'um_after_user_upload','um_remove_unused_uploads', 10, 2 );
|
||||
|
||||
|
||||
/***
|
||||
*** @adds main links to a logout widget
|
||||
***/
|
||||
add_action('um_logout_user_links', 'um_logout_user_links', 100 );
|
||||
function um_logout_user_links( $args ) {
|
||||
/**
|
||||
* Adds main links to a logout widget
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
function um_logout_user_links( $args ) {
|
||||
?>
|
||||
|
||||
<li><a href="<?php echo um_get_core_page('account'); ?>"><?php _e('Your account','ultimate-member'); ?></a></li>
|
||||
<li><a href="<?php echo esc_url( add_query_arg('redirect_to', UM()->permalinks()->get_current_url(true), um_get_core_page('logout') ) ); ?>"><?php _e('Logout','ultimate-member'); ?></a></li>
|
||||
<li><a href="<?php echo um_get_core_page( 'account' ); ?>"><?php _e( 'Your account', 'ultimate-member' ); ?></a></li>
|
||||
<li><a href="<?php echo esc_url( add_query_arg( 'redirect_to', UM()->permalinks()->get_current_url( true ), um_get_core_page( 'logout' ) ) ); ?>"><?php _e('Logout','ultimate-member'); ?></a></li>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'um_logout_user_links', 'um_logout_user_links', 100 );
|
||||
@@ -33,9 +33,14 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Remove users we do not need to show in directory
|
||||
***/
|
||||
/**
|
||||
* Remove users we do not need to show in directory
|
||||
*
|
||||
* @param $query_args
|
||||
* @param $args
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function um_remove_special_users_from_list( $query_args, $args ) {
|
||||
extract( $args );
|
||||
|
||||
@@ -69,13 +74,11 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
if ( UM()->roles()->um_user_can( 'can_view_all' ) && UM()->roles()->um_user_can( 'can_view_roles' ) ) {
|
||||
|
||||
$permissions = UM()->roles()->role_data( um_user( 'role' ) );
|
||||
|
||||
if ( ! empty( $permissions['can_view_roles'] ) )
|
||||
$roles = maybe_unserialize( $permissions['can_view_roles'] );
|
||||
$roles = um_user( 'can_view_roles' );
|
||||
$roles = maybe_unserialize( $roles );
|
||||
|
||||
if ( isset( $roles ) && is_array( $roles ) ) {
|
||||
if ( ! empty( $roles ) ) {
|
||||
$query_args['meta_query'][] = array(
|
||||
'key' => 'role',
|
||||
'value' => $roles,
|
||||
@@ -83,8 +86,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,81 +3,88 @@
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
/***
|
||||
*** @add dynamic profile headers
|
||||
***/
|
||||
add_filter( 'wp_nav_menu_items', 'um_add_custom_message_to_menu', 10, 2 );
|
||||
function um_add_custom_message_to_menu( $items, $args ) {
|
||||
// this feature required logged in user
|
||||
if ( !is_user_logged_in() )
|
||||
return $items;
|
||||
|
||||
/**
|
||||
* Add dynamic profile headers
|
||||
*
|
||||
* @param $items
|
||||
* @param $args
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function um_add_custom_message_to_menu( $items, $args ) {
|
||||
// this feature required logged in user
|
||||
if ( ! is_user_logged_in() )
|
||||
return $items;
|
||||
|
||||
um_fetch_user( get_current_user_id() );
|
||||
$items = UM()->shortcodes()->convert_user_tags( $items );
|
||||
um_reset_user();
|
||||
|
||||
return $items;
|
||||
}
|
||||
add_filter( 'wp_nav_menu_items', 'um_add_custom_message_to_menu', 10, 2 );
|
||||
|
||||
|
||||
/***
|
||||
*** @conditional menu items
|
||||
***/
|
||||
if ( ! is_admin() ) {
|
||||
|
||||
add_filter( 'wp_get_nav_menu_items', 'um_conditional_nav_menu', 9999, 3 );
|
||||
function um_conditional_nav_menu( $items, $menu, $args ) {
|
||||
|
||||
$hide_children_of = array();
|
||||
|
||||
um_fetch_user( get_current_user_id() );
|
||||
$items = UM()->shortcodes()->convert_user_tags( $items );
|
||||
|
||||
foreach ( $items as $key => $item ) {
|
||||
|
||||
$mode = get_post_meta( $item->ID, 'menu-item-um_nav_public', true );
|
||||
$roles = get_post_meta( $item->ID, 'menu-item-um_nav_roles', true );
|
||||
|
||||
$visible = true;
|
||||
|
||||
// hide any item that is the child of a hidden item
|
||||
if ( in_array( $item->menu_item_parent, $hide_children_of ) ) {
|
||||
$visible = false;
|
||||
$hide_children_of[] = $item->ID; // for nested menus
|
||||
}
|
||||
|
||||
if ( isset( $mode ) && $visible ) {
|
||||
|
||||
switch( $mode ) {
|
||||
|
||||
case 2:
|
||||
if ( is_user_logged_in() && ! empty( $roles ) ) {
|
||||
$current_user_roles = um_user( 'roles' );
|
||||
$visible = ( count( array_intersect( $current_user_roles, (array)$roles ) ) > 0 ) ? true : false;
|
||||
} else {
|
||||
$visible = is_user_logged_in() ? true : false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$visible = ! is_user_logged_in() ? true : false;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// add filter to work with plugins that don't use traditional roles
|
||||
$visible = apply_filters( 'um_nav_menu_roles_item_visibility', $visible, $item );
|
||||
|
||||
// unset non-visible item
|
||||
if ( ! $visible ) {
|
||||
$hide_children_of[] = $item->ID; // store ID of item
|
||||
unset( $items[ $key ] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
um_reset_user();
|
||||
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @conditional menu items
|
||||
***/
|
||||
if ( ! is_admin() ) {
|
||||
|
||||
add_filter( 'wp_get_nav_menu_items', 'um_conditional_nav_menu', 9999, 3 );
|
||||
function um_conditional_nav_menu( $items, $menu, $args ) {
|
||||
|
||||
$hide_children_of = array();
|
||||
|
||||
um_fetch_user( get_current_user_id() );
|
||||
|
||||
foreach( $items as $key => $item ) {
|
||||
|
||||
$mode = get_post_meta( $item->ID, 'menu-item-um_nav_public', true );
|
||||
$roles = get_post_meta( $item->ID, 'menu-item-um_nav_roles', true );
|
||||
|
||||
$visible = true;
|
||||
|
||||
// hide any item that is the child of a hidden item
|
||||
if ( in_array( $item->menu_item_parent, $hide_children_of ) ) {
|
||||
$visible = false;
|
||||
$hide_children_of[] = $item->ID; // for nested menus
|
||||
}
|
||||
|
||||
if ( isset( $mode ) && $visible ) {
|
||||
|
||||
switch( $mode ) {
|
||||
|
||||
case 2:
|
||||
if ( is_user_logged_in() && ! empty( $roles ) ) {
|
||||
$visible = in_array( um_user( 'role' ), (array)$roles ) ? true : false;
|
||||
} else {
|
||||
$visible = is_user_logged_in() ? true : false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$visible = ! is_user_logged_in() ? true : false;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// add filter to work with plugins that don't use traditional roles
|
||||
$visible = apply_filters( 'um_nav_menu_roles_item_visibility', $visible, $item );
|
||||
|
||||
// unset non-visible item
|
||||
if ( ! $visible ) {
|
||||
$hide_children_of[] = $item->ID; // store ID of item
|
||||
unset( $items[$key] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
um_reset_user();
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -674,6 +674,11 @@ function um_is_core_page( $page ) {
|
||||
if (isset( $post->ID ) && get_post_meta( $post->ID, '_um_wpml_' . $page, true ) == 1)
|
||||
return true;
|
||||
|
||||
global $sitepress;
|
||||
if ( UM()->config()->permalinks[$page] == wpml_object_id_filter( $post->ID, 'page', true, $sitepress->get_default_language() ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isset( $post->ID )) {
|
||||
$_icl_lang_duplicate_of = get_post_meta( $post->ID, '_icl_lang_duplicate_of', true );
|
||||
|
||||
@@ -988,23 +993,27 @@ function um_is_on_edit_profile() {
|
||||
*/
|
||||
function um_can_view_field( $data ) {
|
||||
|
||||
if (!isset( UM()->fields()->set_mode ))
|
||||
if ( ! isset( UM()->fields()->set_mode ) ) {
|
||||
UM()->fields()->set_mode = '';
|
||||
}
|
||||
|
||||
if (isset( $data['public'] ) && UM()->fields()->set_mode != 'register') {
|
||||
if ( isset( $data['public'] ) && UM()->fields()->set_mode != 'register' ) {
|
||||
|
||||
if (!is_user_logged_in() && $data['public'] != '1') return false;
|
||||
if ( ! is_user_logged_in() && $data['public'] != '1' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_user_logged_in()) {
|
||||
if ( is_user_logged_in() ) {
|
||||
$current_user_roles = um_user( 'roles' );
|
||||
|
||||
if ($data['public'] == '-3' && !um_is_user_himself() && !in_array( UM()->roles()->um_get_user_role( get_current_user_id() ), $data['roles'] ))
|
||||
if ( $data['public'] == '-3' && ! um_is_user_himself() && count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 )
|
||||
return false;
|
||||
|
||||
if (!um_is_user_himself() && $data['public'] == '-1' && !UM()->roles()->um_user_can( 'can_edit_everyone' ))
|
||||
if ( ! um_is_user_himself() && $data['public'] == '-1' && ! UM()->roles()->um_user_can( 'can_edit_everyone' ) )
|
||||
return false;
|
||||
|
||||
if ($data['public'] == '-2' && $data['roles'])
|
||||
if (!in_array( UM()->roles()->um_get_user_role( get_current_user_id() ), $data['roles'] ))
|
||||
if ( $data['public'] == '-2' && $data['roles'] )
|
||||
if ( count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1022,30 +1031,29 @@ function um_can_view_field( $data ) {
|
||||
* @return bool
|
||||
*/
|
||||
function um_can_view_profile( $user_id ) {
|
||||
if (!um_user( 'can_view_all' ) && $user_id != get_current_user_id() && is_user_logged_in()) return false;
|
||||
if ( ! um_user( 'can_view_all' ) && $user_id != get_current_user_id() && is_user_logged_in() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (UM()->roles()->um_current_user_can( 'edit', $user_id )) {
|
||||
if ( UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
if (UM()->user()->is_private_profile( $user_id )) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if ( ! is_user_logged_in() ) {
|
||||
return ! UM()->user()->is_private_profile( $user_id );
|
||||
}
|
||||
|
||||
if (!um_user( 'can_access_private_profile' ) && UM()->user()->is_private_profile( $user_id )) return false;
|
||||
if ( ! um_user( 'can_access_private_profile' ) && UM()->user()->is_private_profile( $user_id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (UM()->roles()->um_user_can( 'can_view_roles' ) && $user_id != get_current_user_id()) {
|
||||
if (!in_array( UM()->roles()->um_get_user_role( $user_id ), UM()->roles()->um_user_can( 'can_view_roles' ) )) {
|
||||
if ( UM()->roles()->um_user_can( 'can_view_roles' ) && $user_id != get_current_user_id() ) {
|
||||
if ( count( array_intersect( UM()->roles()->get_all_user_roles( $user_id ), UM()->roles()->um_user_can( 'can_view_roles' ) ) ) <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user