- fixed user registration;

- phpDoc;
This commit is contained in:
nikitozzzzzzz
2018-03-20 13:24:38 +02:00
parent a85c8741b0
commit 2ce33098b5
54 changed files with 15292 additions and 14163 deletions
@@ -1289,6 +1289,7 @@ foreach ( $member_directories as $directory_id ) {
/**
* Transferring email templates to new logic
*/
$templates_in_theme = 0;
$emails = UM()->config()->email_notifications;
foreach ( $emails as $email_key => $value ) {
@@ -1313,11 +1314,19 @@ foreach ( $emails as $email_key => $value ) {
$fp = fopen( $theme_template_path, "w" );
$result = fputs( $fp, $setting_value );
fclose( $fp );
$templates_in_theme++;
}
}
}
}
if ( $templates_in_theme > 0 ) {
UM()->options()->update( 'email_html', true );
} else {
UM()->options()->update( 'email_html', false );
}
/**
* Transferring menu restriction data
+7 -6
View File
@@ -5,8 +5,15 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Access' ) ) {
/**
* Class Access
* @package um\core
*/
class Access {
/**
* If true then we use individual restrict content options
* for post
@@ -44,9 +51,6 @@ if ( ! class_exists( 'Access' ) ) {
$this->redirect_handler = false;
$this->allow_access = false;
//there is posts (Posts/Page/CPT) filtration if site is accessible
//there also will be redirects if they need
//protect posts types
@@ -475,7 +479,6 @@ if ( ! class_exists( 'Access' ) ) {
* @return bool
*/
function user_can( $user_id, $roles ) {
$user_can = false;
if ( ! empty( $roles ) ) {
@@ -885,7 +888,6 @@ if ( ! class_exists( 'Access' ) ) {
*/
function replace_post_content( $content ) {
$content = $this->current_single_post->post_content;
return $content;
}
@@ -967,7 +969,6 @@ if ( ! class_exists( 'Access' ) ) {
//add all other posts
$filtered_items[] = $menu_item;
}
return $filtered_items;
+37 -7
View File
@@ -5,24 +5,47 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Account' ) ) {
/**
* Class Account
* @package um\core
*/
class Account {
/**
* @var
*/
var $tabs;
/**
* @var string
*/
var $current_tab = 'general';
/**
* @var array
*/
var $register_fields = array();
/**
* @var array
*/
var $tab_output = array();
/**
* Account constructor.
*/
function __construct() {
add_shortcode( 'ultimatemember_account', array( &$this, 'ultimatemember_account' ) );
add_action( 'template_redirect', array( &$this, 'account_page_restrict' ), 10001 );
add_action( 'template_redirect', array( &$this, 'account_submit' ), 10002 );
add_filter( 'um_predefined_fields_hook', array( &$this, 'predefined_fields_hook' ), 1 );
}
@@ -57,6 +80,9 @@ if ( ! class_exists( 'Account' ) ) {
}
/**
* @return mixed|void
*/
function get_tabs() {
$tabs = array();
$tabs[100]['general'] = array(
@@ -415,17 +441,21 @@ if ( ! class_exists( 'Account' ) ) {
* @return mixed
*/
function filter_fields_by_attrs( $fields, $shortcode_args ) {
foreach ( $fields as $k => $field ) {
if ( isset( $shortcode_args[ $field['metakey'] ] ) && 0 == $shortcode_args[ $field['metakey'] ] )
unset( $fields[ $k ] );
}
return $fields;
}
/**
* @param $fields
* @param $id
*
* @return mixed|void
*/
function account_secure_fields( $fields, $id ) {
/**
* UM hook
+7
View File
@@ -5,8 +5,15 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'AJAX_Common' ) ) {
/**
* Class AJAX_Common
* @package um\core
*/
class AJAX_Common {
/**
* AJAX_Common constructor.
*/
+146 -68
View File
@@ -5,27 +5,52 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Builtin' ) ) {
/**
* Class Builtin
* @package um\core
*/
class Builtin {
/**
* @var array
*/
public $predefined_fields = array();
/**
* @var array
*/
var $all_user_fields = array();
/**
* @var array
*/
var $core_fields = array();
/**
* Builtin constructor.
*/
function __construct() {
add_action( 'init', array(&$this, 'set_core_fields'), 1);
add_action( 'init', array(&$this, 'set_predefined_fields'), 1);
add_action( 'init', array(&$this, 'set_custom_fields'), 1);
$this->saved_fields = get_option( 'um_fields' );
}
/***
*** @regular or multi-select/options
***/
/**
* Regular or multi-select/options
*
* @param $field
* @param $attrs
*
* @return bool
*/
function is_dropdown_field( $field, $attrs ) {
if ( isset( $attrs['options'] ) )
@@ -39,52 +64,72 @@ if ( ! class_exists( 'Builtin' ) ) {
return false;
}
/***
*** @get a field
***/
/**
* Get a field
*
* @param $field
*
* @return mixed|string
*/
function get_a_field( $field ) {
$fields = $this->all_user_fields;
if ( isset( $fields[$field] ) ) {
return $fields[$field];
if ( isset( $fields[ $field ] ) ) {
return $fields[ $field ];
}
return '';
}
/***
*** @get specific fields
***/
/**
* Get specific fields
*
* @param $fields
*
* @return array
*/
function get_specific_fields( $fields ) {
$fields = explode(',', $fields);
$array=array();
foreach ($fields as $field ) {
if ( isset( $this->predefined_fields[$field] ) ) {
$array[$field] = $this->predefined_fields[$field];
$fields = explode( ',', $fields );
$array = array();
foreach ( $fields as $field ) {
if ( isset( $this->predefined_fields[ $field ] ) ) {
$array[ $field ] = $this->predefined_fields[ $field ];
}
}
return $array;
}
/***
*** @get specific field
***/
/**
* Get specific field
*
* @param $fields
*
* @return array|mixed
*/
function get_specific_field( $fields ) {
$fields = explode(',', $fields);
$array=array();
foreach ($fields as $field ) {
if ( isset( $this->predefined_fields[$field] ) ) {
$array = $this->predefined_fields[$field];
} else if ( isset( $this->saved_fields[$field] ) ) {
$array = $this->saved_fields[$field];
$fields = explode( ',', $fields );
$array = array();
foreach ( $fields as $field ) {
if ( isset( $this->predefined_fields[ $field ] ) ) {
$array = $this->predefined_fields[ $field ];
} elseif ( isset( $this->saved_fields[ $field ] ) ) {
$array = $this->saved_fields[ $field ];
}
}
return $array;
}
/***
*** @Checks for a unique field error
***/
function unique_field_err( $key ){
if ( empty( $key ) ) return 'Please provide a meta key';
/**
* Checks for a unique field error
*
* @param $key
*
* @return int|string|void
*/
function unique_field_err( $key ) {
if ( empty( $key ) ) return __('Please provide a meta key','ultimate-member');
if ( isset( $this->core_fields[ $key ] ) ) return __('Your meta key is a reserved core field and cannot be used','ultimate-member');
if ( isset( $this->predefined_fields[ $key ] ) ) return __('Your meta key is a predefined reserved key and cannot be used','ultimate-member');
if ( isset( $this->saved_fields[ $key ] ) ) return __('Your meta key already exists in your fields list','ultimate-member');
@@ -92,18 +137,29 @@ if ( ! class_exists( 'Builtin' ) ) {
return 0;
}
/***
*** @check date range errors (start date)
***/
/**
* Check date range errors (start date)
*
* @param $date
*
* @return int|string|void
*/
function date_range_start_err( $date ) {
if ( empty( $date ) ) return __('Please provide a date range beginning','ultimate-member');
if ( ! UM()->validation()->validate_date( $date ) ) return __('Please enter a valid start date in the date range','ultimate-member');
return 0;
}
/***
*** @check date range errors (end date)
***/
/**
* Check date range errors (end date)
*
* @param $date
* @param $start_date
*
* @return int|string|void
*/
function date_range_end_err( $date, $start_date ) {
if ( empty( $date ) ) return __('Please provide a date range end','ultimate-member');
if ( ! UM()->validation()->validate_date( $date ) ) return __('Please enter a valid end date in the date range','ultimate-member');
@@ -111,16 +167,22 @@ if ( ! class_exists( 'Builtin' ) ) {
return 0;
}
/***
*** @Get a core field attrs
***/
/**
* Get a core field attrs
*
* @param $type
*
* @return array|mixed
*/
function get_core_field_attrs( $type ) {
return ( isset( $this->core_fields[$type] ) ) ? $this->core_fields[$type] : array('');
return ( isset( $this->core_fields[ $type ] ) ) ? $this->core_fields[ $type ] : array('');
}
/***
*** @Core Fields
***/
/**
* Core Fields
*/
function set_core_fields() {
$this->core_fields = array(
@@ -556,9 +618,10 @@ if ( ! class_exists( 'Builtin' ) ) {
$this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
}
/***
*** @Predefined Fields
***/
/**
* Predefined Fields
*/
function set_predefined_fields() {
global $wp_roles;
@@ -1115,10 +1178,11 @@ if ( ! class_exists( 'Builtin' ) ) {
$this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
}
/***
*** @Custom Fields
***/
function set_custom_fields(){
/**
* Custom Fields
*/
function set_custom_fields() {
if ( is_array( $this->saved_fields ) ) {
@@ -1141,9 +1205,15 @@ if ( ! class_exists( 'Builtin' ) ) {
}
/***
*** @may be used to show a dropdown, or source for user meta
***/
/**
* May be used to show a dropdown, or source for user meta
*
* @param null $exclude_types
* @param bool $show_all
*
* @return array
*/
function all_user_fields( $exclude_types = null, $show_all = false ) {
$fields_without_metakey = array('block','shortcode','spacing','divider','group');
@@ -1223,10 +1293,13 @@ if ( ! class_exists( 'Builtin' ) ) {
return $all;
}
/***
*** @Possible validation types for fields
***/
function validation_types(){
/**
* Possible validation types for fields
*
* @return mixed
*/
function validation_types() {
$array[0] = __('None','ultimate-member');
$array['alphabetic'] = __('Alphabetic value only','ultimate-member');
@@ -1275,11 +1348,16 @@ if ( ! class_exists( 'Builtin' ) ) {
return $array;
}
/***
*** @Get predefined options
***/
function get( $data ){
switch($data) {
/**
* Get predefined options
*
* @param $data
*
* @return array|mixed|void
*/
function get( $data ) {
switch ( $data ) {
case 'languages':
$array = array(
+49 -28
View File
@@ -5,16 +5,29 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Chart' ) ) {
/**
* Class Chart
* @package um\core
*/
class Chart {
/**
* Chart constructor.
*/
function __construct() {
}
/***
*** @Create a new chart
***/
function create( $args=array() ){
/**
* Create a new chart
*
* @param array $args
*/
function create( $args = array() ) {
$defaults = array(
'id' => 0,
@@ -31,26 +44,41 @@ if ( ! class_exists( 'Chart' ) ) {
);
$args = wp_parse_args( $args, $defaults );
extract($args);
if ($type == 'LineChart'){
/**
* @var $type
*/
extract( $args );
if ( $type == 'LineChart' ) {
$this->linechart( $args );
}
}
/***
*** @LineChart
***/
function linechart( $args ){
extract($args);
?>
/**
* LineChart
*
* @param $args
*/
function linechart( $args ) {
/**
* @var $x_label
* @var $y_label
* @var $vertical_max_lines
* @var $backgroundcolor
* @var $colors
* @var $basebordercolor
* @var $basetextcolor
* @var $data
* @var $id
*/
extract( $args ); ?>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.load( "visualization", "1", {packages:["corechart"]});
function draw_linechart() {
@@ -58,17 +86,13 @@ if ( ! class_exists( 'Chart' ) ) {
data.addColumn('string', '<?php echo $x_label; ?>');
data.addColumn('number', '<?php echo $y_label; ?>');
<?php
<?php /*if ( ! empty( $data_y ) ) {
if (isset($data_y) && !empty($data_y)){
foreach($data_y as $key => $val){
foreach ( $data_y as $key => $val ) {
}
}
?>
}*/ ?>
var min_data = 0;
var max_data = data.getColumnRange(1).max;
@@ -116,19 +140,16 @@ if ( ! class_exists( 'Chart' ) ) {
height: ( vgrid_count * 50 )
};
var chart = new google.visualization.LineChart(document.getElementById('chart_<?php echo $data . $id; ?>'));
chart.draw(data, options);
var chart = new google.visualization.LineChart( document.getElementById( 'chart_<?php echo $data . $id; ?>' ) );
chart.draw( data, options );
}
</script>
<div id="chart_<?php echo $data . $id; ?>">
</div>
<div id="chart_<?php echo $data . $id; ?>"></div>
<?php
}
}
+3
View File
@@ -5,12 +5,15 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Cron' ) ) {
/**
* Class Cron
* @package um\core
*/
class Cron {
/**
* Cron constructor.
*/
+2 -2
View File
@@ -75,13 +75,13 @@ if ( ! class_exists( 'Enqueue' ) ) {
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined('UM_SCRIPT_DEBUG') ) ? '' : '.min';
$exclude = UM()->options()->get('js_css_exclude');
$exclude = UM()->options()->get( 'js_css_exclude' );
if ( is_array( $exclude ) ) {
array_filter( $exclude );
}
if ( $exclude && !is_admin() && is_array( $exclude ) ) {
$c_url = UM()->permalinks()->get_current_url( get_option('permalink_structure') );
$c_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
foreach( $exclude as $match ) {
if ( ! empty( $c_url ) && strstr( $c_url, untrailingslashit( $match ) ) ) {
@@ -5,8 +5,15 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'External_Integrations' ) ) {
/**
* Class External_Integrations
* @package um\core
*/
class External_Integrations {
/**
* Access constructor.
*/
+48 -9
View File
@@ -6,17 +6,31 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Fields' ) ) {
/**
* Class Fields
* @package um\core
*/
class Fields {
/**
* @var string
*/
var $set_mode = '';
function __construct() {
/**
* Fields constructor.
*/
function __construct() {
$this->editing = false;
$this->viewing = false;
$this->timestamp = current_time( 'timestamp' );
}
/**
* Standard checkbox field
*
@@ -45,14 +59,17 @@ if ( ! class_exists( 'Fields' ) ) {
* Shows social links
*/
function show_social_urls() {
$social = array();
$fields = UM()->builtin()->all_user_fields;
foreach ($fields as $field => $args) {
if (isset( $args['advanced'] ) && $args['advanced'] == 'social') {
$social[$field] = $args;
foreach ( $fields as $field => $args ) {
if ( isset( $args['advanced'] ) && $args['advanced'] == 'social' ) {
$social[ $field ] = $args;
}
}
foreach ($social as $k => $arr) {
if (um_profile( $k )) { ?>
foreach ( $social as $k => $arr ) {
if ( um_profile( $k ) ) { ?>
<a href="<?php echo um_filtered_social_link( $k, $arr['match'] ); ?>"
style="background: <?php echo $arr['color']; ?>;" target="_blank" class="um-tip-n"
@@ -85,6 +102,7 @@ if ( ! class_exists( 'Fields' ) ) {
echo '</div>';
}
/**
* Get hidden field
*
@@ -94,7 +112,6 @@ if ( ! class_exists( 'Fields' ) ) {
* @return string
*/
function disabled_hidden_field( $key, $value ) {
return '<input type="hidden" name="' . $key . '" value="' . esc_attr( $value ) . '"/>';
}
@@ -186,6 +203,7 @@ if ( ! class_exists( 'Fields' ) ) {
}
}
/**
* Quickly adds a field from custom fields
*
@@ -218,6 +236,7 @@ if ( ! class_exists( 'Fields' ) ) {
}
}
/**
* Quickly adds a field from pre-defined fields
*
@@ -253,6 +272,7 @@ if ( ! class_exists( 'Fields' ) ) {
}
}
/**
* Duplicates a frield by meta key
*
@@ -290,6 +310,7 @@ if ( ! class_exists( 'Fields' ) ) {
}
/**
* Print field error
*
@@ -317,6 +338,7 @@ if ( ! class_exists( 'Fields' ) ) {
return $output;
}
/**
* Checks if field has a server-side error
*
@@ -328,6 +350,7 @@ if ( ! class_exists( 'Fields' ) ) {
return UM()->form()->has_error( $key );
}
/**
* Returns field error
*
@@ -339,12 +362,13 @@ if ( ! class_exists( 'Fields' ) ) {
return UM()->form()->errors[$key];
}
/**
* Display field label
*
* @param string $label
* @param string $key
* @param data $data
* @param array $data
*
* @return string
*/
@@ -1019,6 +1043,7 @@ if ( ! class_exists( 'Fields' ) ) {
return $value;
}
/**
* Get select options from a callback function
*
@@ -1039,6 +1064,7 @@ if ( ! class_exists( 'Fields' ) ) {
return $arr_options;
}
/**
* Get field type
*
@@ -1054,6 +1080,7 @@ if ( ! class_exists( 'Fields' ) ) {
return '';
}
/**
* Get field label
*
@@ -1089,6 +1116,7 @@ if ( ! class_exists( 'Fields' ) ) {
return __( 'Custom Field', 'ultimate-member' );
}
/**
* Get form fields
*
@@ -1465,6 +1493,11 @@ if ( ! class_exists( 'Fields' ) ) {
}
/**
* @param $option_value
*
* @return mixed|void
*/
function filter_field_non_utf8_value( $option_value ) {
/**
* UM hook
@@ -3189,6 +3222,7 @@ if ( ! class_exists( 'Fields' ) ) {
return ( isset ( $results ) ) ? $results : '';
}
/**
* Get fields in group
*
@@ -3375,6 +3409,7 @@ if ( ! class_exists( 'Fields' ) ) {
return $output;
}
/**
* Gets a field in `view mode`
*
@@ -3812,6 +3847,7 @@ if ( ! class_exists( 'Fields' ) ) {
return $output;
}
/**
* Get new row in form
*
@@ -3898,6 +3934,9 @@ if ( ! class_exists( 'Fields' ) ) {
}
/**
*
*/
function do_ajax_action() {
if (!is_user_logged_in() || !current_user_can( 'manage_options' )) die( __( 'Please login as administrator', 'ultimate-member' ) );
+9 -2
View File
@@ -70,6 +70,9 @@ if ( ! class_exists( 'Files' ) ) {
* Remove file by AJAX
*/
function ajax_remove_file() {
/**
* @var $src
*/
extract( $_REQUEST );
$this->delete_file( $src );
}
@@ -226,6 +229,7 @@ if ( ! class_exists( 'Files' ) ) {
}
}
/**
* Setup upload directory
*/
@@ -442,8 +446,6 @@ if ( ! class_exists( 'Files' ) ) {
$info['um_has_copied'] = $has_copied ? 'yes':'no';
}
return $info;
}
@@ -505,6 +507,7 @@ if ( ! class_exists( 'Files' ) ) {
}
/**
* Make a Folder
*
@@ -1215,6 +1218,10 @@ if ( ! class_exists( 'Files' ) ) {
exit;
}
/**
*
*/
function ajax_file_upload(){
$ret['error'] = null;
$ret = array();
+10
View File
@@ -5,8 +5,18 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'FontIcons' ) ) {
/**
* Class FontIcons
* @package um\core
*/
class FontIcons {
/**
* FontIcons constructor.
*/
function __construct() {
if ( ! get_option( 'um_cache_fonticons' ) ) {
+28 -2
View File
@@ -5,11 +5,30 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Form' ) ) {
/**
* Class Form
* @package um\core
*/
class Form {
/**
* @var null
*/
public $form_suffix;
/**
* @var
*/
var $form_id;
/**
* Form constructor.
*/
function __construct() {
$this->post_form = null;
@@ -27,6 +46,9 @@ if ( ! class_exists( 'Form' ) ) {
}
/**
*
*/
function ajax_muted_action() {
extract( $_REQUEST );
@@ -60,6 +82,9 @@ if ( ! class_exists( 'Form' ) ) {
}
/**
*
*/
function ajax_select_options() {
$arr_options = array();
@@ -442,6 +467,7 @@ if ( ! class_exists( 'Form' ) ) {
return $output;
}
/**
* Assigned roles to a form
* @param integer $post_id
@@ -469,18 +495,18 @@ if ( ! class_exists( 'Form' ) ) {
return $role;
}
/**
* Get form type
* @param integer $post_id
* @return string
*/
function form_type( $post_id ){
$mode = get_post_meta( $post_id, '_um_mode', true );
return $mode;
}
/**
* Get custom field roles
* @param string $custom_fields serialized
+14 -3
View File
@@ -5,17 +5,28 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Logout' ) ) {
/**
* Class Logout
* @package um\core
*/
class Logout {
/**
* Logout constructor.
*/
function __construct() {
add_action('template_redirect', array(&$this, 'logout_page'), 10000 );
}
/***
*** @Logout via logout page
***/
/**
* Logout via logout page
*/
function logout_page() {
$language_code = '';
+31 -6
View File
@@ -5,20 +5,40 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Mail' ) ) {
/**
* Class Mail
* @package um\core
*/
class Mail {
/**
* @var array
*/
var $email_templates = array();
/**
* @var array
*/
var $path_by_slug = array();
function __construct() {
/**
* Mail constructor.
*/
function __construct() {
//mandrill compatibility
add_filter( 'mandrill_nl2br', array( &$this, 'mandrill_nl2br' ) );
add_action( 'plugins_loaded', array( &$this, 'init_paths' ), 99 );
}
/**
* Init paths for email notifications
*/
function init_paths() {
/**
* UM hook
@@ -53,14 +73,12 @@ if ( ! class_exists( 'Mail' ) ) {
* @return bool
*/
function mandrill_nl2br( $nl2br, $message = '' ) {
// text emails
if ( ! UM()->options()->get( 'email_html' ) ) {
$nl2br = true;
}
return $nl2br;
}
@@ -355,6 +373,11 @@ if ( ! class_exists( 'Mail' ) ) {
}
/**
* @param $template_name
*
* @return mixed|void
*/
function get_template_filename( $template_name ) {
/**
* UM hook
@@ -380,6 +403,7 @@ if ( ! class_exists( 'Mail' ) ) {
return apply_filters( 'um_change_email_template_file', $template_name );
}
/**
* Locate a template and return the path for inclusion.
*
@@ -439,13 +463,11 @@ if ( ! class_exists( 'Mail' ) ) {
* @return string
*/
function set_content_type( $content_type ) {
if ( UM()->options()->get( 'email_html' ) ) {
return 'text/html';
} else {
return 'text/plain';
}
}
@@ -488,6 +510,9 @@ if ( ! class_exists( 'Mail' ) ) {
}
/**
* Delete Email Notification Template
*/
function delete_email_template() {
$template = $_POST['email_key'];
+49 -19
View File
@@ -5,10 +5,24 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Members' ) ) {
/**
* Class Members
* @package um\core
*/
class Members {
/**
* @var
*/
var $results;
/**
* Members constructor.
*/
function __construct() {
add_filter('user_search_columns', array(&$this, 'user_search_columns'), 99 );
@@ -26,9 +40,14 @@ if ( ! class_exists( 'Members' ) ) {
}
/***
*** @user_search_columns
***/
/**
* User_search_columns
*
* @param $search_columns
*
* @return array
*/
function user_search_columns( $search_columns ){
if ( is_admin() ) {
$search_columns[] = 'display_name';
@@ -36,20 +55,25 @@ if ( ! class_exists( 'Members' ) ) {
return $search_columns;
}
/***
*** @Members page allowed?
***/
function access_members() {
/**
* Members page allowed?
*/
function access_members() {
if ( UM()->options()->get('members_page') == 0 && um_is_core_page( 'members' ) ) {
um_redirect_home();
}
}
/***
*** @tag conversion for member directory
***/
/**
* Tag conversion for member directory
*
* @param $string
* @param $array
*
* @return mixed
*/
function convert_tags( $string, $array ) {
$search = array(
@@ -64,9 +88,12 @@ if ( ! class_exists( 'Members' ) ) {
return $string;
}
/***
*** @show filter
***/
/**
* Show filter
*
* @param $filter
*/
function show_filter( $filter ) {
$fields = UM()->builtin()->all_user_fields;
@@ -243,6 +270,7 @@ if ( ! class_exists( 'Members' ) ) {
}
/**
* Display assigned roles in search filter 'role' field
* @param array $attrs
@@ -275,11 +303,13 @@ if ( ! class_exists( 'Members' ) ) {
}
/***
*** @Generate a loop of results
***/
/**
* Generate a loop of results
*
* @param $args
*
* @return mixed|void
*/
function get_members( $args ) {
global $wpdb, $post;
+14 -5
View File
@@ -5,17 +5,26 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Modal' ) ) {
/**
* Class Modal
* @package um\core
*/
class Modal {
/**
* Modal constructor.
*/
function __construct() {
add_action('wp_footer', array(&$this, 'load_modal_content'), 9);
}
/***
*** @Load modal content
***/
/**
* Load modal content
*/
function load_modal_content(){
if ( !is_admin() ) {
foreach( glob( um_path . 'templates/modal/*.php' ) as $modal_content) {
+14 -3
View File
@@ -5,12 +5,23 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Options' ) ) {
class Options {
var $options = array();
/**
* Access constructor.
* Class Options
* @package um\core
*/
class Options {
/**
* @var array
*/
var $options = array();
/**
* Options constructor.
*/
function __construct() {
$this->init_variables();
+51 -18
View File
@@ -5,10 +5,24 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Password' ) ) {
/**
* Class Password
* @package um\core
*/
class Password {
/**
* @var
*/
var $reset_request;
/**
* Password constructor.
*/
function __construct() {
add_shortcode('ultimatemember_password', array(&$this, 'ultimatemember_password'));
@@ -21,9 +35,10 @@ if ( ! class_exists( 'Password' ) ) {
}
/***
*** @a listener to password reset uri
***/
/**
* A listener to password reset uri
*/
function listen_to_password_reset_uri() {
if ( isset($_REQUEST['act']) && $_REQUEST['act'] == 'reset_password' && isset($_REQUEST['hash']) && strlen($_REQUEST['hash']) == 40 &&
@@ -49,9 +64,12 @@ if ( ! class_exists( 'Password' ) ) {
}
/***
*** @reset url
***/
/**
* reset url
*
* @return bool|string
*/
function reset_url(){
if ( !um_user('reset_pass_hash') ) return false;
@@ -67,9 +85,10 @@ if ( ! class_exists( 'Password' ) ) {
}
/***
*** @we are on password reset page
***/
/**
* we are on password reset page
*/
function password_reset(){
if ( um_is_core_page('password-reset') ) {
@@ -79,6 +98,7 @@ if ( ! class_exists( 'Password' ) ) {
}
/**
* Password page form
*/
@@ -189,9 +209,14 @@ if ( ! class_exists( 'Password' ) ) {
}
/***
*** @Add class based on shortcode
***/
/**
* Add class based on shortcode
*
* @param $mode
*
* @return mixed|string|void
*/
function get_class( $mode ) {
$classes = 'um-'.$mode;
@@ -233,16 +258,24 @@ if ( ! class_exists( 'Password' ) ) {
return $classes;
}
/***
*** @Shortcode
***/
/**
* Shortcode
*
* @param array $args
*
* @return string
*/
function ultimatemember_password( $args = array() ) {
return $this->load( $args );
}
/***
*** @Load a module with global function
***/
/**
* Load a module with global function
*
* @param $args
*
* @return string
*/
function load( $args ) {
ob_start();
+25
View File
@@ -6,8 +6,17 @@ if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Plugin_Updater' ) ) {
/**
* Class Plugin_Updater
* @package um\core
*/
class Plugin_Updater {
/**
* Plugin_Updater constructor.
*/
function __construct() {
//create cron event
if ( ! wp_next_scheduled( 'um_check_extensions_licenses' ) ) {
@@ -26,6 +35,7 @@ if ( ! class_exists( 'Plugin_Updater' ) ) {
add_filter( 'plugins_api', array( &$this, 'um_plugins_api_filter' ), 9999, 3 );
}
/**
* Get all paid UM extensions
*
@@ -126,11 +136,17 @@ if ( ! class_exists( 'Plugin_Updater' ) ) {
}
/**
* Remove CRON events on deactivation hook
*/
function um_plugin_updater_deactivation_hook() {
wp_clear_scheduled_hook( 'um_check_extensions_licenses' );
}
/**
* Check license function
*/
function um_checklicenses() {
$exts = $this->um_get_active_plugins();
@@ -301,6 +317,15 @@ if ( ! class_exists( 'Plugin_Updater' ) ) {
}
/**
* Download extension URL
*
* @param $download_url
* @param $slug
* @param $data
*
* @return string
*/
function extend_download_url( $download_url, $slug, $data ) {
$url = get_site_url( get_current_blog_id() );
+83 -30
View File
@@ -5,21 +5,45 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Profile' ) ) {
/**
* Class Profile
* @package um\core
*/
class Profile {
/**
* @var array
*/
public $arr_user_slugs = array();
/**
* @var array
*/
public $arr_user_roles = array();
/**
* @var
*/
var $active_tab;
/**
* Profile constructor.
*/
function __construct() {
add_action('template_redirect', array(&$this, 'active_tab'), 10002);
add_action('template_redirect', array(&$this, 'active_subnav'), 10002);
add_action( 'template_redirect', array( &$this, 'active_tab' ), 10002 );
add_action( 'template_redirect', array( &$this, 'active_subnav' ), 10002 );
}
/**
* Delete profile avatar AJAX handler
*/
function ajax_delete_profile_photo() {
/**
* @var $user_id
@@ -33,6 +57,9 @@ if ( ! class_exists( 'Profile' ) ) {
}
/**
* Delete cover photo AJAX handler
*/
function ajax_delete_cover_photo() {
/**
* @var $user_id
@@ -46,9 +73,11 @@ if ( ! class_exists( 'Profile' ) ) {
}
/***
*** @all tab data
***/
/**
* All tab data
*
* @return mixed|void
*/
function tabs() {
/**
@@ -99,21 +128,27 @@ if ( ! class_exists( 'Profile' ) ) {
return $tabs;
}
/***
*** @tabs that are active
***/
function tabs_active(){
/**
* Tabs that are active
*
* @return mixed|void
*/
function tabs_active() {
$tabs = $this->tabs();
foreach( $tabs as $id => $info ) {
if ( ! UM()->options()->get('profile_tab_'.$id) && !isset( $info['_builtin'] ) && !isset( $info['custom'] ) )
unset( $tabs[$id] );
unset( $tabs[ $id ] );
}
return $tabs;
}
/***
*** @primary tabs only
***/
/**
* Primary tabs only
*
* @return array
*/
function tabs_primary(){
$tabs = $this->tabs();
$primary = array();
@@ -125,9 +160,12 @@ if ( ! class_exists( 'Profile' ) ) {
return $primary;
}
/***
*** @Activated tabs in backend
***/
/**
* Activated tabs in backend
*
* @return string
*/
function tabs_enabled(){
$tabs = $this->tabs();
foreach( $tabs as $id => $info ){
@@ -140,9 +178,12 @@ if ( ! class_exists( 'Profile' ) ) {
return ( isset( $primary ) ) ? $primary : '';
}
/***
*** @Privacy options
***/
/**
* Privacy options
*
* @return array
*/
function tabs_privacy() {
$privacy = array(
0 => 'Anyone',
@@ -155,9 +196,14 @@ if ( ! class_exists( 'Profile' ) ) {
return $privacy;
}
/***
*** @Check if the user can view the current tab
***/
/**
* Check if the user can view the current tab
*
* @param $tab
*
* @return bool
*/
function can_view_tab( $tab ) {
$privacy = intval( UM()->options()->get( 'profile_tab_' . $tab . '_privacy' ) );
$can_view = false;
@@ -194,9 +240,12 @@ if ( ! class_exists( 'Profile' ) ) {
return $can_view;
}
/***
*** @Get active_tab
***/
/**
* Get active_tab
*
* @return mixed|void
*/
function active_tab() {
$this->active_tab = UM()->options()->get('profile_menu_default_tab');
@@ -231,9 +280,12 @@ if ( ! class_exists( 'Profile' ) ) {
return $this->active_tab;
}
/***
*** @Get active active_subnav
***/
/**
* Get active active_subnav
*
* @return mixed|null
*/
function active_subnav() {
$this->active_subnav = null;
@@ -245,6 +297,7 @@ if ( ! class_exists( 'Profile' ) ) {
return $this->active_subnav;
}
/**
* Show meta in profile
*
+145 -60
View File
@@ -5,11 +5,30 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Query' ) ) {
/**
* Class Query
* @package um\core
*/
class Query {
/**
* @var array
*/
public $wp_pages = array();
/**
* @var array
*/
public $roles = array();
/**
* Query constructor.
*/
function __construct() {
@@ -56,9 +75,11 @@ if ( ! class_exists( 'Query' ) ) {
}
/***
*** @get wp pages
***/
/**
* Get wp pages
*
* @return array|string
*/
function wp_pages() {
global $wpdb;
@@ -87,30 +108,37 @@ if ( ! class_exists( 'Query' ) ) {
return $array;
}
/***
*** @get all forms
***/
/**
* Get all forms
*
* @return mixed
*/
function forms() {
$results = array();
$args = array(
'post_type' => 'um_form',
'posts_per_page' => 200,
'post_status' => array('publish')
);
$query = new \WP_Query( $args );
foreach( $query->posts as $post ) {
foreach ( $query->posts as $post ) {
setup_postdata( $post );
$results[ $post->ID ] = $post->post_title;
}
return $results;
}
/***
*** @Do custom queries
***/
/**
* Do custom queries
*
* @param $args
*
* @return array|bool|int|\WP_Query
*/
function make( $args ) {
$defaults = array(
@@ -164,9 +192,14 @@ if ( ! class_exists( 'Query' ) ) {
}
}
/***
*** @Get last users
***/
/**
* Get last users
*
* @param int $number
*
* @return array
*/
function get_recent_users($number = 5){
$args = array( 'fields' => 'ID', 'number' => $number, 'orderby' => 'user_registered', 'order' => 'desc' );
@@ -174,30 +207,39 @@ if ( ! class_exists( 'Query' ) ) {
return $users->results;
}
/***
*** @Count users by status
***/
/**
* Count users by status
*
* @param $status
*
* @return int
*/
function count_users_by_status( $status ) {
$args = array( 'fields' => 'ID', 'number' => 0 );
if ( $status == 'unassigned' ) {
$args['meta_query'][] = array(array('key' => 'account_status','compare' => 'NOT EXISTS'));
$users = new \WP_User_Query( $args );
foreach( $users->results as $user ) {
foreach ( $users->results as $user ) {
update_user_meta( $user, 'account_status', 'approved' );
}
} else {
$args['meta_query'][] = array(array('key' => 'account_status','value' => $status,'compare' => '='));
}
$users = new \WP_User_Query( $args );
return count($users->results);
return count( $users->results );
}
/***
*** @Get users by status
***/
function get_users_by_status($status, $number = 5){
global $wpdb;
/**
* Get users by status
*
* @param $status
* @param int $number
*
* @return array
*/
function get_users_by_status($status, $number = 5){
$args = array( 'fields' => 'ID', 'number' => $number, 'orderby' => 'user_registered', 'order' => 'desc' );
$args['meta_query'][] = array(
@@ -213,70 +255,108 @@ if ( ! class_exists( 'Query' ) ) {
}
/***
*** @Count all users
***/
function count_users(){
/**
* Count all users
*
* @return mixed
*/
function count_users() {
$result = count_users();
return $result['total_users'];
}
/***
*** @Using wpdb instead of update_post_meta
***/
/**
* Using wpdb instead of update_post_meta
*
* @param $key
* @param $post_id
* @param $new_value
*/
function update_attr( $key, $post_id, $new_value ){
update_post_meta( $post_id, '_um_' . $key, $new_value );
}
/***
*** @get data
***/
function get_attr( $key, $post_id ){
/**
* Get data
*
* @param $key
* @param $post_id
*
* @return mixed
*/
function get_attr( $key, $post_id ) {
$meta = get_post_meta( $post_id, '_um_' . $key, true );
return $meta;
}
/***
*** @delete data
***/
function delete_attr( $key, $post_id ){
/**
* Delete data
*
* @param $key
* @param $post_id
*
* @return bool
*/
function delete_attr( $key, $post_id ) {
$meta = delete_post_meta( $post_id, '_um_' . $key );
return $meta;
}
/***
*** @Checks if post has a specific meta key
***/
function has_post_meta($key, $value=null, $post_id=null ){
if (!$post_id){
/**
* Checks if post has a specific meta key
*
* @param $key
* @param null $value
* @param null $post_id
*
* @return bool
*/
function has_post_meta( $key, $value = null, $post_id = null ) {
if ( ! $post_id ) {
global $post;
$post_id = $post->ID;
}
if ($value ){
if ( get_post_meta($post_id, $key, true) == $value )
if ( $value ) {
if ( get_post_meta( $post_id, $key, true ) == $value ) {
return true;
}
} else {
if ( get_post_meta($post_id, $key, true) )
if ( get_post_meta( $post_id, $key, true ) ) {
return true;
}
}
return false;
}
/***
*** @Get posts with specific meta key/value
***/
function find_post_id($post_type, $key, $value){
/**
* Get posts with specific meta key/value
*
* @param $post_type
* @param $key
* @param $value
*
* @return bool
*/
function find_post_id( $post_type, $key, $value ) {
$posts = get_posts( array( 'post_type' => $post_type, 'meta_key' => $key, 'meta_value' => $value ) );
if ( isset($posts[0]) && !empty($posts) )
if ( isset( $posts[0] ) && ! empty( $posts ) )
return $posts[0]->ID;
return false;
}
/***
*** @Get post data
***/
/**
* Get post data
*
* @param $post_id
*
* @return mixed
*/
function post_data( $post_id ) {
$array['form_id'] = $post_id;
$mode = $this->get_attr('mode', $post_id);
@@ -305,6 +385,7 @@ if ( ! class_exists( 'Query' ) ) {
return $array;
}
/**
* Capture selected value
*
@@ -314,7 +395,6 @@ if ( ! class_exists( 'Query' ) ) {
* @return int|mixed|null|string
*/
function get_meta_value( $key, $array_key = null, $fallback = null ) {
global $post;
$post_id = get_the_ID();
$try = get_post_meta( $post_id, $key, true );
@@ -337,9 +417,14 @@ if ( ! class_exists( 'Query' ) ) {
return ! empty( $fallback ) ? $fallback : $none;
}
/***
*** @Checks if its a core page of UM
***/
/**
* Checks if its a core page of UM
*
* @param $post_id
*
* @return bool|mixed
*/
function is_core( $post_id ){
$is_core = get_post_meta($post_id, '_um_core', true);
if ( $is_core != '' ) {
+26 -5
View File
@@ -5,19 +5,40 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Register' ) ) {
/**
* Class Register
* @package um\core
*/
class Register {
function __construct(){
add_action("um_after_register_fields", array( $this, 'add_nonce' ) );
add_action("um_submit_form_register", array( $this, 'verify_nonce'), 1, 1);
/**
* Register constructor.
*/
function __construct() {
add_action( "um_after_register_fields", array( $this, 'add_nonce' ) );
add_action( "um_submit_form_register", array( $this, 'verify_nonce' ), 1, 1 );
}
public function add_nonce(){
/**
* Add registration form notice
*/
public function add_nonce() {
wp_nonce_field( 'um_register_form' );
}
public function verify_nonce( $args ){
/**
* Verify nonce handler
*
* @param $args
*
* @return mixed
*/
public function verify_nonce( $args ) {
/**
* UM hook
*
+131 -1
View File
@@ -5,18 +5,65 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'REST_API' ) ) {
/**
* Class REST_API
* @package um\core
*/
class REST_API {
/**
*
*/
const VERSION = '1.0';
/**
* @var bool|int|null
*/
private $pretty_print = false;
/**
* @var bool|mixed|void
*/
public $log_requests = true;
/**
* @var bool
*/
private $is_valid_request = false;
/**
* @var int
*/
private $user_id = 0;
/**
* @var
*/
private $stats;
/**
* @var array
*/
private $data = array();
/**
* @var bool
*/
private $override = true;
/**
* REST_API constructor.
*/
public function __construct() {
add_action( 'init', array( $this, 'add_endpoint' ) );
@@ -55,15 +102,23 @@ if ( ! class_exists( 'REST_API' ) ) {
$this->log_requests = apply_filters( 'um_api_log_requests', $this->log_requests );
}
/**
* Registers a new rewrite endpoint for accessing the API
*
* @param $rewrite_rules
*/
public function add_endpoint( $rewrite_rules ) {
add_rewrite_endpoint( 'um-api', EP_ALL );
}
/**
* Registers query vars for API access
*
* @param $vars
*
* @return array
*/
public function query_vars( $vars ) {
@@ -88,6 +143,7 @@ if ( ! class_exists( 'REST_API' ) ) {
return $vars;
}
/**
* Validate the API request
*/
@@ -118,8 +174,13 @@ if ( ! class_exists( 'REST_API' ) ) {
}
}
/**
* Retrieve the user ID based on the public key provided
*
* @param string $key
*
* @return bool|mixed|null|string
*/
public function get_user( $key = '' ) {
global $wpdb, $wp_query;
@@ -146,6 +207,7 @@ if ( ! class_exists( 'REST_API' ) ) {
return false;
}
/**
* Displays a missing authentication error if all the parameters aren't
* provided
@@ -158,6 +220,7 @@ if ( ! class_exists( 'REST_API' ) ) {
$this->output( 401 );
}
/**
* Displays an authentication failed error if the user failed to provide valid credentials
*/
@@ -169,6 +232,7 @@ if ( ! class_exists( 'REST_API' ) ) {
$this->output( 401 );
}
/**
* Displays an invalid API key error if the API key provided couldn't be validated
*/
@@ -292,8 +356,13 @@ if ( ! class_exists( 'REST_API' ) ) {
$this->output();
}
/**
* Get some stats
*
* @param $args
*
* @return array|mixed|void
*/
public function get_stats( $args ) {
global $wpdb;
@@ -333,8 +402,13 @@ if ( ! class_exists( 'REST_API' ) ) {
return $response;
}
/**
* Update user API query
*
* @param $args
*
* @return array
*/
public function update_user( $args ) {
extract( $args );
@@ -400,6 +474,10 @@ if ( ! class_exists( 'REST_API' ) ) {
/**
* Process Get users API Request
*
* @param $args
*
* @return array
*/
public function get_users( $args ) {
extract( $args );
@@ -483,8 +561,13 @@ if ( ! class_exists( 'REST_API' ) ) {
return $response;
}
/**
* Process delete user via API
*
* @param $args
*
* @return array
*/
public function delete_user( $args ) {
extract( $args );
@@ -511,8 +594,13 @@ if ( ! class_exists( 'REST_API' ) ) {
return $response;
}
/**
* Process Get user API Request
*
* @param $args
*
* @return array|mixed|void
*/
public function get_auser( $args ) {
extract( $args );
@@ -648,8 +736,13 @@ if ( ! class_exists( 'REST_API' ) ) {
return $response;
}
/**
* Get source
*
* @param $image
*
* @return string
*/
public function getsrc( $image ) {
if (preg_match('/<img.+?src(?: )*=(?: )*[\'"](.*?)[\'"]/si', $image, $arrResult)) {
@@ -658,8 +751,11 @@ if ( ! class_exists( 'REST_API' ) ) {
return '';
}
/**
* Determines the kind of query requested and also ensure it is a valid query
*
* @return null
*/
public function get_query_mode() {
global $wp_query;
@@ -708,6 +804,7 @@ if ( ! class_exists( 'REST_API' ) ) {
return $query;
}
/**
* Get page number
*/
@@ -717,6 +814,7 @@ if ( ! class_exists( 'REST_API' ) ) {
return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
}
/**
* Retrieve the output format
*/
@@ -749,13 +847,15 @@ if ( ! class_exists( 'REST_API' ) ) {
return apply_filters( 'um_api_output_format', $format );
}
/**
* Log each API request, if enabled
*
* @param array $data
*/
private function log_request( $data = array() ) {
if ( ! $this->log_requests )
return;
}
@@ -766,6 +866,7 @@ if ( ! class_exists( 'REST_API' ) ) {
return $this->data;
}
/**
* Output Query in either JSON/XML. The query data is outputted as JSON
* by default
@@ -877,6 +978,7 @@ if ( ! class_exists( 'REST_API' ) ) {
die();
}
/**
* Modify User Profile Page fields
*
@@ -925,8 +1027,14 @@ if ( ! class_exists( 'REST_API' ) ) {
return $content;
}
/**
* Generate new API keys for a user
*
* @param int $user_id
* @param bool $regenerate
*
* @return bool
*/
public function generate_api_key( $user_id = 0, $regenerate = false ) {
@@ -954,8 +1062,13 @@ if ( ! class_exists( 'REST_API' ) ) {
return true;
}
/**
* Revoke a users API keys
*
* @param int $user_id
*
* @return bool
*/
public function revoke_api_key( $user_id = 0 ) {
@@ -983,6 +1096,8 @@ if ( ! class_exists( 'REST_API' ) ) {
/**
* Generate and Save API key
*
* @param $user_id
*/
public function update_key( $user_id ) {
if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['um_set_api_key'] ) ) {
@@ -998,8 +1113,13 @@ if ( ! class_exists( 'REST_API' ) ) {
}
}
/**
* Generate the public key for a user
*
* @param string $user_email
*
* @return string
*/
private function generate_public_key( $user_email = '' ) {
$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
@@ -1007,8 +1127,13 @@ if ( ! class_exists( 'REST_API' ) ) {
return $public;
}
/**
* Generate the secret key for a user
*
* @param int $user_id
*
* @return string
*/
private function generate_private_key( $user_id = 0 ) {
$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
@@ -1016,8 +1141,13 @@ if ( ! class_exists( 'REST_API' ) ) {
return $secret;
}
/**
* Retrieve the user's token
*
* @param int $user_id
*
* @return string
*/
private function get_token( $user_id = 0 ) {
$user = get_userdata( $user_id );
+37 -21
View File
@@ -5,10 +5,19 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Rewrite' ) ) {
/**
* Class Rewrite
* @package um\core
*/
class Rewrite {
function __construct() {
/**
* Rewrite constructor.
*/
function __construct() {
add_filter( 'query_vars', array(&$this, 'query_vars'), 10, 1 );
add_action( 'init', array( &$this, 'rewrite_rules'), 100000000 );
@@ -17,15 +26,18 @@ if ( ! class_exists( 'Rewrite' ) ) {
add_action( 'template_redirect', array( &$this, 'locate_user_profile'), 9999 );
//add rewrite rules
add_filter( 'rewrite_rules_array', array( &$this, '_add_rewrite_rules' ), 10, 1 );
}
/***
*** @modify global query vars
***/
/**
* Modify global query vars
*
* @param $public_query_vars
*
* @return array
*/
function query_vars( $public_query_vars ) {
$public_query_vars[] = 'um_user';
$public_query_vars[] = 'um_tab';
@@ -42,6 +54,13 @@ if ( ! class_exists( 'Rewrite' ) ) {
}
/**
* Add UM rewrite rules
*
* @param $rules
*
* @return array
*/
function _add_rewrite_rules( $rules ) {
$newrules = array();
@@ -50,9 +69,10 @@ if ( ! class_exists( 'Rewrite' ) ) {
return $newrules + $rules;
}
/***
*** @setup rewrite rules
***/
/**
* Setup rewrite rules
*/
function rewrite_rules() {
if ( isset( UM()->config()->permalinks['user'] ) ) {
@@ -138,9 +158,10 @@ if ( ! class_exists( 'Rewrite' ) ) {
}
/***
*** @author page to user profile redirect
***/
/**
* Author page to user profile redirect
*/
function redirect_author_page() {
if ( UM()->options()->get( 'author_redirect' ) && is_author() ) {
$id = get_query_var( 'author' );
@@ -149,9 +170,10 @@ if ( ! class_exists( 'Rewrite' ) ) {
}
}
/***
*** @locate/display a profile
***/
/**
* Locate/display a profile
*/
function locate_user_profile() {
global $post;
@@ -230,11 +252,6 @@ if ( ! class_exists( 'Rewrite' ) ) {
$query = UM()->permalinks()->get_query_array();
$url = um_user_profile_url( um_user( 'ID' ) );
/*if ( empty( $url ) ) {
//if empty profile slug - generate it and re-get profile URL
UM()->user()->generate_profile_slug( um_user( 'ID' ) );
$url = um_user_profile_url();
}*/
if ( $query ) {
foreach ( $query as $key => $val ) {
@@ -277,6 +294,5 @@ if ( ! class_exists( 'Rewrite' ) ) {
}
}
}
+11 -2
View File
@@ -6,12 +6,20 @@ if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Roles_Capabilities' ) ) {
/**
* Class Roles_Capabilities
* @package um\core
*/
class Roles_Capabilities {
/**
* Roles_Capabilities constructor.
*/
function __construct() {
add_action( 'wp_roles_init', array( &$this, 'um_roles_init' ), 99999 );
}
@@ -253,6 +261,7 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
return apply_filters( 'um_set_user_role', $new_role, $user_id, $user );
}
/**
* Remove user role
*
+14 -2
View File
@@ -4,10 +4,17 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Router' ) ) {
class Router {
/**
*
* Class Router
* @package um\core
*/
class Router {
/**
* Run backend process
*/
function backend_requests() {
$ip = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
@@ -48,6 +55,8 @@ if ( ! class_exists( 'Router' ) ) {
/**
* Request process
*
* @param $params array
* @return bool
*/
@@ -74,6 +83,9 @@ if ( ! class_exists( 'Router' ) ) {
}
/**
* Run frontend process
*/
function frontend_requests() {
$ip = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
$user_id = get_current_user_id();
+23 -10
View File
@@ -5,18 +5,32 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Setup' ) ) {
/**
* Class Setup
* @package um\core
*/
class Setup {
/**
* @var array
*/
var $setup_shortcode = array();
/**
* Setup constructor.
*/
function __construct() {
//add_action('init', array(&$this, 'install_basics'), 9);
}
/**
* Run setup
*/
function run_setup() {
$this->install_basics();
$this->install_default_forms();
@@ -25,18 +39,18 @@ if ( ! class_exists( 'Setup' ) ) {
}
/***
*** @Basics
***/
/**
* Basics
*/
function install_basics() {
if ( ! get_option( '__ultimatemember_sitekey' ) )
update_option( '__ultimatemember_sitekey', str_replace( array( 'http://', 'https://' ), '', sanitize_user( get_bloginfo('url') ) ) . '-' . wp_generate_password( 20, false ) );
}
/***
*** @Default Forms
***/
/**
* Default Forms
*/
function install_default_forms() {
$options = get_option( 'um_options' );
@@ -218,7 +232,6 @@ if ( ! class_exists( 'Setup' ) ) {
* Set UM roles meta to Default WP roles
*/
function set_default_role_meta() {
//for set accounts without account status approved status
UM()->query()->count_users_by_status( 'unassigned' );
+81 -30
View File
@@ -5,8 +5,18 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Shortcodes' ) ) {
/**
* Class Shortcodes
* @package um\core
*/
class Shortcodes {
/**
* Shortcodes constructor.
*/
function __construct() {
$this->message_mode = false;
@@ -165,12 +175,16 @@ if ( ! class_exists( 'Shortcodes' ) ) {
}
/***
*** @emoji support
/**
* Emoji support
*
* @param $content
*
* @return mixed|string
*/
function emotize($content) {
$content = stripslashes($content);
foreach ($this->emoji as $code => $val) {
function emotize( $content ) {
$content = stripslashes( $content );
foreach ( $this->emoji as $code => $val ) {
$regex = str_replace(array('(', ')'), array("\\" . '(', "\\" . ')'), $code);
$content = preg_replace('/(' . $regex . ')(\s|$)/', '<img src="' . $val . '" alt="' . $code . '" title="' . $code . '" class="emoji" />$2', $content);
}
@@ -188,21 +202,25 @@ if ( ! class_exists( 'Shortcodes' ) ) {
}
/***
*** @extend body classes
/**
* Extend body classes
*
* @param $classes
*
* @return array
*/
function body_class($classes) {
function body_class( $classes ) {
$array = UM()->config()->permalinks;
if (!$array) {
if ( ! $array ) {
return $classes;
}
foreach ($array as $slug => $info) {
if (um_is_core_page($slug)) {
foreach ( $array as $slug => $info ) {
if ( um_is_core_page( $slug ) ) {
$classes[] = 'um-page-' . $slug;
if (is_user_logged_in()) {
if ( is_user_logged_in() ) {
$classes[] = 'um-page-loggedin';
} else {
$classes[] = 'um-page-loggedout';
@@ -211,15 +229,18 @@ if ( ! class_exists( 'Shortcodes' ) ) {
}
}
if( um_is_core_page('user') && um_is_user_himself() ){
if ( um_is_core_page( 'user' ) && um_is_user_himself() ) {
$classes[] = 'um-own-profile';
}
return $classes;
}
/***
*** @Retrieve core login form
/**
* Retrieve core login form
*
* @return int
*/
function core_login_form() {
$forms = get_posts(array('post_type' => 'um_form', 'posts_per_page' => 1, 'meta_key' => '_um_core', 'meta_value' => 'login'));
@@ -262,8 +283,13 @@ if ( ! class_exists( 'Shortcodes' ) ) {
}
/***
*** @Add class based on shortcode
/**
* Add class based on shortcode
*
* @param $mode
* @param array $args
*
* @return mixed|string|void
*/
function get_class($mode, $args = array()) {
@@ -314,6 +340,7 @@ if ( ! class_exists( 'Shortcodes' ) ) {
return $classes;
}
/**
* Logged-in only content
*
@@ -367,17 +394,27 @@ if ( ! class_exists( 'Shortcodes' ) ) {
return $output;
}
/***
*** @Shortcode
/**
* Shortcode
*
* @param array $args
*
* @return string
*/
function ultimatemember($args = array()) {
return $this->load($args);
function ultimatemember( $args = array() ) {
return $this->load( $args );
}
/***
*** @Load a module with global function
/**
* Load a module with global function
*
* @param $args
*
* @return string
*/
function load($args) {
function load( $args ) {
ob_start();
$defaults = array();
@@ -657,8 +694,12 @@ if ( ! class_exists( 'Shortcodes' ) ) {
}
/***
*** @Checks if a template file exists
/**
* Checks if a template file exists
*
* @param $template
*
* @return bool
*/
function template_exists($template) {
@@ -672,8 +713,13 @@ if ( ! class_exists( 'Shortcodes' ) ) {
return false;
}
/***
*** @Get File Name without path and extension
/**
* Get File Name without path and extension
*
* @param $file
*
* @return mixed|string
*/
function get_template_name($file) {
$file = basename($file);
@@ -681,8 +727,13 @@ if ( ! class_exists( 'Shortcodes' ) ) {
return $file;
}
/***
*** @Get Templates
/**
* Get Templates
*
* @param null $excluded
*
* @return mixed
*/
function get_templates($excluded = null) {
+55 -24
View File
@@ -5,10 +5,24 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Tracking' ) ) {
/**
* Class Tracking
* @package um\core
*/
class Tracking {
/**
* @var
*/
private $data;
/**
* Tracking constructor.
*/
public function __construct() {
$this->schedule_send();
@@ -20,9 +34,11 @@ if ( ! class_exists( 'Tracking' ) ) {
}
/***
*** @Opt-in tracking
***/
/**
* Opt-in tracking
*
* @param $action
*/
function um_admin_do_action__opt_into_tracking( $action ) {
UM()->options()->update( 'um_allow_tracking', 1 );
update_option( 'um_tracking_notice', 1 );
@@ -33,9 +49,11 @@ if ( ! class_exists( 'Tracking' ) ) {
}
/***
*** @Opt-out of tracking
***/
/**
* Opt-out of tracking
*
* @param $action
*/
function um_admin_do_action__opt_out_of_tracking( $action ) {
UM()->options()->update( 'um_allow_tracking', 0 );
update_option('um_tracking_notice', 1 );
@@ -43,9 +61,11 @@ if ( ! class_exists( 'Tracking' ) ) {
exit( wp_redirect( remove_query_arg('um_adm_action') ) );
}
/***
*** @setup info array
***/
/**
* Setup info array
*
*/
private function setup_data() {
$data = array();
@@ -95,25 +115,34 @@ if ( ! class_exists( 'Tracking' ) ) {
}
/***
*** @check if tracking is allowed
***/
/**
* Check if tracking is allowed
*
* @return int
*/
private function tracking_allowed() {
if ( ! UM()->options()->get( 'allow_tracking' ) )
return 0;
return 1;
}
/***
*** @get last send time
***/
/**
* Get last send time
*
* @return mixed|void
*/
private function get_last_send() {
return get_option( 'um_tracking_last_send' );
}
/***
*** @send a report
***/
/**
* Send a report
*
* @param bool $override
*/
public function send_checkin( $override = false ) {
if( ! $this->tracking_allowed() && ! $override )
@@ -146,16 +175,18 @@ if ( ! class_exists( 'Tracking' ) ) {
update_option( '__ultimatemember_coupon_sent', 1 );
}
/***
*** @run a scheduled report
***/
/**
* Run a scheduled report
*/
private function schedule_send() {
add_action( 'um_daily_scheduled_events', array( $this, 'send_checkin' ) );
}
/***
*** @show admin notices
***/
/**
* Show admin notices
*/
public function admin_notices() {
if( ! current_user_can( 'manage_options' ) )
+202 -186
View File
@@ -6,8 +6,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'User' ) ) {
/**
* Class User
* @package um\core
*/
class User {
/**
* User constructor.
*/
function __construct() {
$this->id = 0;
@@ -75,6 +85,9 @@ if ( ! class_exists( 'User' ) ) {
}
/**
*
*/
function check_membership() {
if ( ! is_user_logged_in() )
return;
@@ -538,23 +551,27 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @Remove cached queue from Users backend
***/
/**
* Remove cached queue from Users backend
*/
function remove_cached_queue() {
delete_option( 'um_cached_users_queue' );
}
/***
*** @Converts object to array
***/
function toArray($obj)
{
if (is_object($obj)) $obj = (array)$obj;
if (is_array($obj)) {
/**
* Converts object to array
*
* @param $obj
*
* @return array
*/
function toArray( $obj ) {
if ( is_object( $obj ) ) $obj = (array)$obj;
if ( is_array( $obj ) ) {
$new = array();
foreach ($obj as $key => $val) {
$new[$key] = $this->toArray($val);
foreach ( $obj as $key => $val ) {
$new[ $key ] = $this->toArray( $val );
}
} else {
$new = $obj;
@@ -563,6 +580,12 @@ if ( ! class_exists( 'User' ) ) {
return $new;
}
/**
* @param $user_id
*
* @return mixed|string|void
*/
function get_cached_data( $user_id ) {
$disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
@@ -602,43 +625,46 @@ if ( ! class_exists( 'User' ) ) {
return '';
}
/**
* @param $user_id
* @param $profile
*/
function setup_cache( $user_id, $profile ) {
$disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
if( $disallow_cache ){
return '';
if ( $disallow_cache ) {
return;
}
update_option( "um_cache_userdata_{$user_id}", $profile, false );
}
/**
* @param $user_id
*/
function remove_cache( $user_id ) {
delete_option( "um_cache_userdata_{$user_id}" );
}
/**
* @function set()
* This method lets you set a user. For example, to retrieve a profile or anything related to that user.
*
* @description This method lets you set a user. For example, to retrieve a profile or anything related to that user.
* @usage <?php UM()->user()->set( $user_id, $clean = false ); ?>
*
* @usage <?php $ultimatemember->user->set( $user_id, $clean = false ); ?>
*
* @param $user_id (numeric) (optional) Which user to retrieve. A numeric user ID
* @param $clean (boolean) (optional) Should be true or false. Basically, if you did not provide a user ID It will set the current logged in user as a profile
*
* @returns This API method does not return anything. It sets user profile and permissions and allow you to retrieve any details for that user.
* @param null|int $user_id Which user to retrieve. A numeric user ID
* @param bool $clean Should be true or false. Basically, if you did not provide a user ID It will set the current logged in user as a profile
*
* @example The following example makes you set a user and retrieve their display name after that using the user API.
<?php
$ultimatemember->user->set( 12 );
$display_name = $ultimatemember->user->profile['display_name']; // Should print user display name
UM()->user()->set( 12 );
$display_name = UM()->user()->profile['display_name']; // Should print user display name
?>
*
*
*/
function set( $user_id = null, $clean = false ) {
@@ -780,17 +806,21 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @reset user data
***/
/**
* Reset user data
*
* @param bool $clean
*/
function reset( $clean = false ){
$this->set(0, $clean);
}
/***
*** @Clean user profile
***/
function clean(){
/**
* Clean user profile
*/
function clean() {
foreach($this->profile as $key => $value){
foreach($this->banned_keys as $ban){
if (strstr($key, $ban) || is_numeric($key) )
@@ -799,29 +829,23 @@ if ( ! class_exists( 'User' ) ) {
}
}
/**
* @function auto_login()
* This method lets you auto sign-in a user to your site.
*
* @description This method lets you auto sign-in a user to your site.
* @usage <?php UM()->user()->auto_login( $user_id, $rememberme = false ); ?>
*
* @usage <?php $ultimatemember->user->auto_login( $user_id, $rememberme = false ); ?>
*
* @param $user_id (numeric) (required) Which user ID to sign in automatically
* @param $rememberme (boolean) (optional) Should be true or false. If you want the user sign in session to use cookies, use true
*
* @returns Sign in the specified user automatically.
* @param int $user_id Which user ID to sign in automatically
* @param int|bool $rememberme Should be true or false. If you want the user sign in session to use cookies, use true
*
* @example The following example lets you sign in a user automatically by their ID.
<?php $ultimatemember->user->auto_login( 2 ); ?>
<?php UM()->user()->auto_login( 2 ); ?>
*
*
* @example The following example lets you sign in a user automatically by their ID and makes the plugin remember their session.
<?php $ultimatemember->user->auto_login( 10, true ); ?>
*
<?php UM()->user()->auto_login( 10, true ); ?>
*
*/
function auto_login( $user_id, $rememberme = 0 ) {
@@ -836,9 +860,12 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @Set user's registration details
***/
/**
* Set user's registration details
*
* @param $submitted
*/
function set_registration_details( $submitted ) {
if ( isset( $submitted['user_pass'] ) ) {
@@ -1018,18 +1045,19 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @Set user's hash for password reset
***/
function password_reset_hash(){
/**
* Set user's hash for password reset
*/
function password_reset_hash() {
$this->profile['reset_pass_hash'] = UM()->validation()->generate();
$this->update_usermeta_info('reset_pass_hash');
}
/***
*** @Set user's hash
***/
/**
* Set user's hash
*/
function assign_secretkey() {
/**
* UM hook
@@ -1070,47 +1098,42 @@ if ( ! class_exists( 'User' ) ) {
* ?>
*/
do_action( 'um_after_user_hash_is_changed' );
}
/***
*** @password reset email
***/
function password_reset(){
/**
* Password reset email
*/
function password_reset() {
$this->password_reset_hash();
UM()->mail()->send( um_user('user_email'), 'resetpw_email' );
}
/***
*** @password changed email
***/
/**
* Password changed email
*/
function password_changed(){
UM()->mail()->send( um_user('user_email'), 'changedpw_email' );
}
/**
* @function approve()
* This method approves a user membership and sends them an optional welcome/approval e-mail.
*
* @description This method approves a user membership and sends them an optional welcome/approval e-mail.
*
* @usage <?php $ultimatemember->user->approve(); ?>
*
* @returns Approves a user membership.
* @usage <?php UM()->user()->approve(); ?>
*
* @example Approve a pending user and allow him to sign-in to your site.
<?php
um_fetch_user( 352 );
$ultimatemember->user->approve();
UM()->user()->approve();
?>
*
*
*/
function approve(){
function approve() {
$user_id = um_user('ID');
delete_option( "um_cache_userdata_{$user_id}" );
@@ -1149,34 +1172,30 @@ if ( ! class_exists( 'User' ) ) {
do_action( 'um_after_user_is_approved', um_user( 'ID' ) );
}
/***
*** @pending email
***/
/**
* Pending email
*/
function email_pending() {
$this->assign_secretkey();
$this->set_status('awaiting_email_confirmation');
UM()->mail()->send( um_user('user_email'), 'checkmail_email' );
}
/**
* @function pending()
* This method puts a user under manual review by administrator and sends them an optional e-mail.
*
* @description This method puts a user under manual review by administrator and sends them an optional e-mail.
*
* @usage <?php $ultimatemember->user->pending(); ?>
*
* @returns Puts a user under review and sends them an email optionally.
* @usage <?php UM()->user()->pending(); ?>
*
* @example An example of putting a user pending manual review
<?php
um_fetch_user( 54 );
$ultimatemember->user->pending();
UM()->user()->pending();
?>
*
*
*/
function pending() {
@@ -1184,40 +1203,33 @@ if ( ! class_exists( 'User' ) ) {
UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
}
/**
* @function reject()
* This method rejects a user membership and sends them an optional e-mail.
*
* @description This method rejects a user membership and sends them an optional e-mail.
*
* @usage <?php $ultimatemember->user->reject(); ?>
*
* @returns Rejects a user membership.
* @usage <?php UM()->user()->reject(); ?>
*
* @example Reject a user membership example
<?php
um_fetch_user( 114 );
$ultimatemember->user->reject();
UM()->user()->reject();
?>
*
*
*/
function reject(){
function reject() {
$this->set_status('rejected');
UM()->mail()->send( um_user('user_email'), 'rejected_email' );
}
/**
* @function deactivate()
* This method deactivates a user membership and sends them an optional e-mail.
*
* @description This method deactivates a user membership and sends them an optional e-mail.
*
* @usage <?php $ultimatemember->user->deactivate(); ?>
*
* @returns Deactivates a user membership.
* @usage <?php UM()->user()->deactivate(); ?>
*
* @example Deactivate a user membership with the following example
@@ -1227,11 +1239,9 @@ if ( ! class_exists( 'User' ) ) {
$ultimatemember->user->deactivate();
?>
*
*
*/
function deactivate(){
function deactivate() {
$this->set_status( 'inactive' );
/**
* UM hook
@@ -1258,9 +1268,11 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @delete user
***/
/**
* Delete user
*
* @param bool $send_mail
*/
function delete( $send_mail = true ) {
/**
* UM hook
@@ -1331,14 +1343,13 @@ if ( ! class_exists( 'User' ) ) {
}
/**
* @function get_role()
* This method gets a user role in slug format. e.g. member
*
* @description This method gets a user role in slug format. e.g. member
* @usage <?php UM()->user()->get_role(); ?>
*
* @usage <?php $ultimatemember->user->get_role(); ?>
*
* @returns The user role's slug.
* @return string
*
* @example Do something if the user's role is paid-member
@@ -1346,15 +1357,13 @@ if ( ! class_exists( 'User' ) ) {
um_fetch_user( 12 );
if ( $ultimatemember->user->get_role() == 'paid-member' ) {
if ( UM()->user()->get_role() == 'paid-member' ) {
// Show this to paid customers
} else {
// You are a free member
}
?>
*
*
*/
function get_role() {
@@ -1370,36 +1379,34 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @Update one key in user meta
***/
/**
* Update one key in user meta
*
* @param $key
*/
function update_usermeta_info( $key ) {
// delete the key first just in case
delete_user_meta( $this->id, $key );
update_user_meta( $this->id, $key, $this->profile[$key] );
}
/**
* @function delete_meta()
* This method can be used to delete user's meta key.
*
* @description This method can be used to delete user's meta key.
* @usage <?php UM()->user()->delete_meta( $key ); ?>
*
* @usage <?php $ultimatemember->user->delete_meta( $key ); ?>
*
* @param $key (string) (required) The meta field key to remove from user
*
* @returns This method will not return anything. The specified meta key will be deleted from database for the specified user.
* @param string $key The meta field key to remove from user
*
* @example Delete user's age field
<?php
um_fetch_user( 15 );
$ultimatemember->user->delete_meta( 'age' );
UM()->user()->delete_meta( 'age' );
?>
*
*
*/
function delete_meta( $key ){
@@ -1407,9 +1414,11 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @Get admin actions for individual user
***/
/**
* Get admin actions for individual user
*
* @return array|bool
*/
function get_admin_actions() {
$items = array();
$actions = array();
@@ -1444,30 +1453,27 @@ if ( ! class_exists( 'User' ) ) {
return $items;
}
/**
* @function is_private_profile()
* This method checks if give user profile is private.
*
* @description This method checks if give user profile is private.
* @usage <?php UM()->user()->is_private_profile( $user_id ); ?>
*
* @usage <?php $ultimatemember->user->is_private_profile( $user_id ); ?>
* @param int $user_id A user ID must be passed to check if the user profile is private
*
* @param $user_id (numeric) (required) A user ID must be passed to check if the user profile is private
*
* @returns Returns true if user profile is private and false if user profile is public.
* @return bool
*
* @example This example display a specific user's name If his profile is public
<?php
um_fetch_user( 60 );
$is_private = $ultimatemember->user->is_private_profile( 60 );
if ( !$is_private ) {
$is_private = UM()->user()->is_private_profile( 60 );
if ( ! $is_private ) {
echo 'User is public and his name is ' . um_user('display_name');
}
?>
*
*
*/
function is_private_profile( $user_id ) {
@@ -1478,30 +1484,27 @@ if ( ! class_exists( 'User' ) ) {
return false;
}
/**
* @function is_approved()
* This method can be used to determine If a certain user is approved or not.
*
* @description This method can be used to determine If a certain user is approved or not.
* @usage <?php UM()->user()->is_approved( $user_id ); ?>
*
* @usage <?php $ultimatemember->user->is_approved( $user_id ); ?>
* @param int $user_id The user ID to check approval status for
*
* @param $user_id (numeric) (required) The user ID to check approval status for
*
* @returns True if user is approved and false if user is not approved.
* @return bool
*
* @example Do something If a user's membership is approved
<?php
if ( $ultimatemember->user->is_approved( 55 ) {
if ( UM()->user()->is_approved( 55 ) {
// User account is approved
} else {
// User account is not approved
}
?>
*
*
*/
function is_approved( $user_id ) {
@@ -1512,9 +1515,15 @@ if ( ! class_exists( 'User' ) ) {
return false;
}
/***
*** @Is private
***/
/**
* Is private
*
* @param $user_id
* @param $case
*
* @return bool|mixed|void
*/
function is_private_case( $user_id, $case ) {
$privacy = get_user_meta( $user_id, 'profile_privacy', true );
@@ -1549,12 +1558,15 @@ if ( ! class_exists( 'User' ) ) {
return false;
}
/***
*** @update files
***/
/**
* Update files
*
* @param $changes
*/
function update_files( $changes ) {
foreach( $changes as $key => $uri ) {
foreach ( $changes as $key => $uri ) {
$src = um_is_temp_upload( $uri );
UM()->files()->new_user_upload( $this->id, $src, $key );
}
@@ -1562,9 +1574,11 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @update profile
***/
/**
* Update profile
*
* @param $changes
*/
function update_profile( $changes ) {
$args['ID'] = $this->id;
@@ -1630,9 +1644,15 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @user exists by meta key and value
***/
/**
* User exists by meta key and value
*
* @param $key
* @param $value
*
* @return bool|int
*/
function user_has_metadata( $key, $value ) {
$value = UM()->validation()->safe_name_in_url( $value );
@@ -1652,9 +1672,13 @@ if ( ! class_exists( 'User' ) ) {
}
/***
*** @user exists by name
***/
/**
* User exists by name
*
* @param $value
*
* @return bool
*/
function user_exists_by_name( $value ) {
// Permalink base
@@ -1726,33 +1750,30 @@ if ( ! class_exists( 'User' ) ) {
/**
* @function user_exists_by_id()
* This method checks if a user exists or not in your site based on the user ID.
*
* @description This method checks if a user exists or not in your site based on the user ID.
* @usage <?php UM()->user()->user_exists_by_id( $user_id ); ?>
*
* @usage <?php $ultimatemember->user->user_exists_by_id( $user_id ); ?>
* @param int $user_id A user ID must be passed to check if the user exists
*
* @param $user_id (numeric) (required) A user ID must be passed to check if the user exists
*
* @returns Returns true if user exists and false if user does not exist.
* @return bool|int
*
* @example Basic Usage
<?php
$boolean = $ultimatemember->user->user_exists_by_id( 15 );
$boolean = UM()->user()->user_exists_by_id( 15 );
if ( $boolean ) {
// That user exists
}
?>
*
*
*/
function user_exists_by_id( $user_id ) {
$aux = get_userdata( intval( $user_id ) );
if($aux==false){
if( $aux == false ) {
return false;
} else {
return $user_id;
@@ -1761,31 +1782,26 @@ if ( ! class_exists( 'User' ) ) {
/**
* @function user_exists_by_email_as_username()
* This method checks if a user exists or not in your site based on the user email as username
*
* @description This method checks if a user exists or not in your site based on the user email as username
* @param string $slug A user slug must be passed to check if the user exists
*
* @usage <?php $ultimatemember->user->user_exists_by_email_as_username( $slug ); ?>
* @usage <?php UM()->user()->user_exists_by_email_as_username( $slug ); ?>
*
* @param $slug (string) (required) A user slug must be passed to check if the user exists
*
* @returns Returns true if user exists and false if user does not exist.
* @return bool
*
* @example Basic Usage
<?php
$boolean = $ultimatemember->user->user_exists_by_email_as_username( 'calumgmail-com' );
$boolean = UM()->user()->user_exists_by_email_as_username( 'calumgmail-com' );
if ( $boolean ) {
// That user exists
}
?>
*
*
*/
function user_exists_by_email_as_username( $slug ){
function user_exists_by_email_as_username( $slug ) {
$user_id = false;
+24 -13
View File
@@ -1,21 +1,29 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
/**
* Processes the requests of UM actions
*
*/
add_action('init','um_action_request_process', 10);
function um_action_request_process(){
if ( is_admin() ) return false;
if ( ! is_user_logged_in() ) return false;
if ( ! isset( $_REQUEST['um_action'] ) ) return false;
if ( isset( $_REQUEST['uid'] ) && ! UM()->user()->user_exists_by_id( $_REQUEST['uid'] ) ) return false;
function um_action_request_process() {
if ( is_admin() ) {
return;
}
if ( ! is_user_logged_in() ) {
return;
}
if ( ! isset( $_REQUEST['um_action'] ) ) {
return;
}
if ( isset( $_REQUEST['uid'] ) && ! UM()->user()->user_exists_by_id( $_REQUEST['uid'] ) ) {
return;
}
if ( isset( $_REQUEST['uid'] ) ) {
if ( is_super_admin( $_REQUEST['uid'] ) )
if ( is_super_admin( $_REQUEST['uid'] ) ) {
wp_die( __( 'Super administrators can not be modified.','ultimate-member' ) );
}
}
if ( isset( $_REQUEST['um_action'] ) && $_REQUEST['um_action'] != "edit" && ! current_user_can( 'edit_users' ) ) {
wp_die( __( 'You do not have enough permissions to do that.','ultimate-member') );
@@ -61,7 +69,9 @@ if ( ! defined( 'ABSPATH' ) ) exit;
break;
case 'um_switch_user':
if ( !current_user_can('delete_users') ) return;
if ( !current_user_can('delete_users') ) {
return;
}
UM()->user()->auto_login( $_REQUEST['uid'] );
exit( wp_redirect( UM()->permalinks()->get_current_url( true ) ) );
break;
@@ -105,4 +115,5 @@ if ( ! defined( 'ABSPATH' ) ) exit;
break;
}
}
}
add_action( 'init', 'um_action_request_process', 10 );
+47 -38
View File
@@ -1,15 +1,14 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @Error handling: blocked emails
***/
add_action('um_submit_form_errors_hook__blockedemails', 'um_submit_form_errors_hook__blockedemails', 10);
function um_submit_form_errors_hook__blockedemails($args){
$emails = UM()->options()->get('blocked_emails');
if ( !$emails )
/**
* Error handling: blocked emails
*
* @param $args
*/
function um_submit_form_errors_hook__blockedemails( $args ) {
$emails = UM()->options()->get( 'blocked_emails' );
if ( ! $emails )
return;
$emails = array_map("rtrim", explode("\n", $emails));
@@ -39,14 +38,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
exit( wp_redirect( esc_url( add_query_arg('err', 'blocked_domain') ) ) );
}
}
add_action( 'um_submit_form_errors_hook__blockedemails', 'um_submit_form_errors_hook__blockedemails', 10 );
}
/***
*** @Error handling: blocked IPs
***/
add_action('um_submit_form_errors_hook__blockedips', 'um_submit_form_errors_hook__blockedips', 10);
function um_submit_form_errors_hook__blockedips($args){
/**
* Error handling: blocked IPs
*
* @param $args
*/
function um_submit_form_errors_hook__blockedips($args){
$ips = UM()->options()->get('blocked_ips');
if ( !$ips )
return;
@@ -60,13 +61,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
exit( wp_redirect( esc_url( add_query_arg('err', 'blocked_ip') ) ) );
}
}
}
}
add_action( 'um_submit_form_errors_hook__blockedips', 'um_submit_form_errors_hook__blockedips', 10 );
/***
*** @Error handling: blocked words during sign up
***/
add_action('um_submit_form_errors_hook__blockedwords', 'um_submit_form_errors_hook__blockedwords', 10);
function um_submit_form_errors_hook__blockedwords($args){
/**
* Error handling: blocked words during sign up
*
* @param $args
*/
function um_submit_form_errors_hook__blockedwords( $args ) {
$form_id = $args['form_id'];
$mode = $args['mode'];
$fields = unserialize( $args['custom_fields'] );
@@ -75,8 +79,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
if ( $words != '' ) {
$words = array_map("rtrim", explode("\n", $words));
if( isset( $fields ) && ! empty( $fields ) && is_array( $fields ) ){
foreach( $fields as $key => $array ) {
if ( ! empty( $fields ) && is_array( $fields ) ) {
foreach ( $fields as $key => $array ) {
if ( isset($array['validate']) && in_array( $array['validate'], array('unique_username','unique_email','unique_username_or_email') ) ) {
if ( ! UM()->form()->has_error( $key ) && isset( $args[$key] ) && in_array( $args[$key], $words ) ) {
UM()->form()->add_error( $key, __('You are not allowed to use this word as your username.','ultimate-member') );
@@ -86,14 +90,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
}
}
add_action( 'um_submit_form_errors_hook__blockedwords', 'um_submit_form_errors_hook__blockedwords', 10 );
}
/***
*** @Error handling
***/
add_action('um_submit_form_errors_hook', 'um_submit_form_errors_hook', 10);
function um_submit_form_errors_hook( $args ){
/**
* Error handling
*
* @param $args
*/
function um_submit_form_errors_hook( $args ) {
$form_id = $args['form_id'];
$mode = $args['mode'];
@@ -251,13 +257,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
}
}
add_action( 'um_submit_form_errors_hook', 'um_submit_form_errors_hook', 10 );
/***
*** @Error processing hook : standard
***/
add_action('um_submit_form_errors_hook_', 'um_submit_form_errors_hook_', 10);
function um_submit_form_errors_hook_( $args ){
/**
* Error processing hook : standard
*
* @param $args
*/
function um_submit_form_errors_hook_( $args ) {
$form_id = $args['form_id'];
$mode = $args['mode'];
$fields = unserialize( $args['custom_fields'] );
@@ -267,7 +276,6 @@ if ( ! defined( 'ABSPATH' ) ) exit;
UM()->form()->add_error('profile_photo', sprintf(__('%s is required.','ultimate-member'), 'Profile Photo' ) );
}
if ( ! empty( $fields ) ) {
foreach ( $fields as $key => $array ) {
@@ -733,4 +741,5 @@ if ( ! defined( 'ABSPATH' ) ) exit;
} // end if ( isset in args array )
}
}
}
add_action( 'um_submit_form_errors_hook_', 'um_submit_form_errors_hook_', 10 );
+51 -44
View File
@@ -1,30 +1,30 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @adds a form identifier to form
***/
add_action('um_after_form_fields', 'um_add_form_identifier');
function um_add_form_identifier($args){ ?>
<input type="hidden" name="form_id" id="form_id_<?php echo $args['form_id']; ?>" value="<?php echo $args['form_id']; ?>" />
<?php
}
/***
*** @adds a spam timestamp
***/
add_action('um_after_form_fields', 'um_add_security_checks');
add_action('um_account_page_hidden_fields', 'um_add_security_checks');
function um_add_security_checks($args){
if ( is_admin() ) return;
echo '<input type="hidden" name="timestamp" class="um_timestamp" value="'. current_time( 'timestamp' ) .'" />';
/**
* Adds a form identifier to form
*
* @param $args
*/
function um_add_form_identifier( $args ) {
?>
<input type="hidden" name="form_id" id="form_id_<?php echo $args['form_id']; ?>" value="<?php echo $args['form_id']; ?>" />
<?php
}
add_action( 'um_after_form_fields', 'um_add_form_identifier' );
/**
* Adds a spam timestamp
*
* @param $args
*/
function um_add_security_checks( $args ) {
if ( is_admin() ) {
return;
} ?>
<input type="hidden" name="timestamp" class="um_timestamp" value="<?php echo current_time( 'timestamp' ) ?>" />
<p class="<?php echo UM()->honeypot; ?>_name">
<label for="<?php echo UM()->honeypot . '_' . $args['form_id']; ?>"><?php _e( 'Only fill in if you are not human' ); ?></label>
@@ -32,26 +32,33 @@ if ( ! defined( 'ABSPATH' ) ) exit;
</p>
<?php
}
add_action( 'um_after_form_fields', 'um_add_security_checks' );
add_action( 'um_account_page_hidden_fields', 'um_add_security_checks' );
/**
* Makes the honeypot invisible
*/
function um_add_form_honeypot_css() {
?>
<style type="text/css">
.<?php echo UM()->honeypot; ?>_name {
display: none !important;
}
/***
*** @makes the honeypot invisible
***/
add_action('wp_head', 'um_add_form_honeypot_css');
function um_add_form_honeypot_css() { ?>
<style type="text/css">.<?php echo UM()->honeypot; ?>_name { display: none !important; }</style>
<?php }
/***
*** @empty the honeypot value
***/
add_action('wp_footer', 'um_add_form_honeypot_js', 99999999999999999 );
function um_add_form_honeypot_js() { ?>
<script type="text/javascript">jQuery( '#<?php echo UM()->honeypot; ?>' ).val( '' );</script>
</style>
<?php
}
}
add_action( 'wp_head', 'um_add_form_honeypot_css' );
/**
* Empty the honeypot value
*/
function um_add_form_honeypot_js() {
?>
<script type="text/javascript">
jQuery( '#<?php echo UM()->honeypot; ?>' ).val( '' );
</script>
<?php
}
add_action( 'wp_footer', 'um_add_form_honeypot_js', 99999999999999999 );
+87 -58
View File
@@ -3,11 +3,12 @@
if ( ! defined( 'ABSPATH' ) ) exit;
/**
/**
* Error procesing hook for login
*
* @param $args
*/
add_action('um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_login', 10);
function um_submit_form_errors_hook_login( $args ){
function um_submit_form_errors_hook_login( $args ) {
$is_email = false;
$form_id = $args['form_id'];
@@ -88,13 +89,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
if( UM()->form()->has_error( $field ) || UM()->form()->has_error( $user_password ) || UM()->form()->count_errors() > 0 ) {
do_action( 'wp_login_failed', $user_name );
}
}
}
add_action( 'um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_login', 10 );
/**
/**
* Display the login errors from other plugins
*
* @param $args
*/
add_action( 'um_before_login_fields', 'um_display_login_errors' );
function um_display_login_errors( $args ) {
function um_display_login_errors( $args ) {
$error = '';
if( UM()->form()->count_errors() > 0 ) {
@@ -116,12 +120,15 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
}
}
add_action( 'um_before_login_fields', 'um_display_login_errors' );
/***
*** @login checks thru the frontend login
***/
add_action('um_submit_form_errors_hook_logincheck', 'um_submit_form_errors_hook_logincheck', 9999 );
function um_submit_form_errors_hook_logincheck($args){
/**
* Login checks thru the frontend login
*
* @param $args
*/
function um_submit_form_errors_hook_logincheck( $args ) {
// Logout if logged in
if ( is_user_logged_in() ) {
wp_logout();
@@ -148,28 +155,37 @@ if ( ! defined( 'ABSPATH' ) ) exit;
exit( wp_redirect( um_get_core_page('login') ) );
}
}
}
add_action( 'um_submit_form_errors_hook_logincheck', 'um_submit_form_errors_hook_logincheck', 9999 );
/***
*** @store last login timestamp
***/
add_action('um_on_login_before_redirect', 'um_store_lastlogin_timestamp', 10, 1);
function um_store_lastlogin_timestamp( $user_id ) {
/**
* Store last login timestamp
*
* @param $user_id
*/
function um_store_lastlogin_timestamp( $user_id ) {
update_user_meta( $user_id, '_um_last_login', current_time( 'timestamp' ) );
}
}
add_action( 'um_on_login_before_redirect', 'um_store_lastlogin_timestamp', 10, 1 );
add_action( 'wp_login', 'um_store_lastlogin_timestamp_' );
function um_store_lastlogin_timestamp_( $login ) {
$user = get_user_by('login',$login);
/**
* @param $login
*/
function um_store_lastlogin_timestamp_( $login ) {
$user = get_user_by( 'login', $login );
um_store_lastlogin_timestamp( $user->ID );
}
}
add_action( 'wp_login', 'um_store_lastlogin_timestamp_' );
/**
/**
* Login user process
*
* @param array $args
*/
function um_user_login( $args ) {
function um_user_login( $args ) {
extract( $args );
$rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
@@ -254,15 +270,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
break;
}
}
add_action( 'um_user_login', 'um_user_login', 10 );
}
add_action( 'um_user_login', 'um_user_login', 10 );
/***
*** @form processing
***/
add_action( 'um_submit_form_login', 'um_submit_form_login', 10 );
function um_submit_form_login( $args ) {
/**
* Form processing
*
* @param $args
*/
function um_submit_form_login( $args ) {
if ( ! isset( UM()->form()->errors ) ) {
/**
@@ -307,13 +324,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
* ?>
*/
do_action( 'um_user_login_extra_hook', $args );
}
}
add_action( 'um_submit_form_login', 'um_submit_form_login', 10 );
/***
*** @Show the submit button
***/
add_action('um_after_login_fields', 'um_add_submit_button_to_login', 1000);
function um_add_submit_button_to_login($args){
/**
* Show the submit button
*
* @param $args
*/
function um_add_submit_button_to_login( $args ) {
// DO NOT add when reviewing user's details
if ( UM()->user()->preview == true && is_admin() ) return;
@@ -390,9 +410,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
* }
* ?>
*/
$secondary_btn_url = apply_filters('um_login_form_button_two_url', $secondary_btn_url, $args );
?>
$secondary_btn_url = apply_filters('um_login_form_button_two_url', $secondary_btn_url, $args ); ?>
<div class="um-col-alt">
@@ -417,13 +435,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
</div>
<?php
}
}
add_action( 'um_after_login_fields', 'um_add_submit_button_to_login', 1000 );
/***
*** @Display a forgot password link
***/
add_action('um_after_login_fields', 'um_after_login_submit', 1001);
function um_after_login_submit( $args ){
/**
* Display a forgot password link
*
* @param $args
*/
function um_after_login_submit( $args ) {
if ( $args['forgot_pass_link'] == 0 ) return;
?>
@@ -434,21 +455,29 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<?php
}
add_action( 'um_after_login_fields', 'um_after_login_submit', 1001 );
/***
*** @Show Fields
***/
add_action('um_main_login_fields', 'um_add_login_fields', 100);
function um_add_login_fields($args){
/**
* Show Fields
*
* @param $args
*/
function um_add_login_fields($args){
echo UM()->fields()->display( 'login', $args );
}
}
add_action('um_main_login_fields', 'um_add_login_fields', 100);
/**
/**
* Remove authenticate filter
* @uses 'wp_authenticate_username_password_before'
*
* @param $user
* @param $username
* @param $password
*/
add_action('wp_authenticate_username_password_before','um_auth_username_password_before',10,3);
function um_auth_username_password_before( $user, $username, $password ){
function um_auth_username_password_before( $user, $username, $password ) {
remove_filter( 'authenticate', 'wp_authenticate_username_password', 20 );
}
}
add_action( 'wp_authenticate_username_password_before', 'um_auth_username_password_before', 10, 3 );
+32 -23
View File
@@ -1,13 +1,12 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
/**
* Member Directory Search
*
* @param $args
*/
add_action('um_members_directory_search', 'um_members_directory_search');
function um_members_directory_search( $args ) {
function um_members_directory_search( $args ) {
$search_filters = array();
if ( isset($args['search_fields']) ) {
@@ -93,24 +92,28 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<?php
}
}
}
add_action( 'um_members_directory_search', 'um_members_directory_search' );
/**
/**
* Pre-display Member Directory
*
* @param $args
*/
add_action('um_pre_directory_shortcode', 'um_pre_directory_shortcode');
function um_pre_directory_shortcode($args) {
function um_pre_directory_shortcode( $args ) {
extract( $args );
UM()->members()->results = UM()->members()->get_members( $args );
}
add_action( 'um_pre_directory_shortcode', 'um_pre_directory_shortcode' );
}
/**
/**
* Member Directory Header
*
* @param $args
*/
add_action('um_members_directory_head', 'um_members_directory_head');
function um_members_directory_head( $args ) {
function um_members_directory_head( $args ) {
extract( $args );
if ( isset($_REQUEST['um_search']) ) {
@@ -130,14 +133,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
</div>
<?php }
}
add_action( 'um_members_directory_head', 'um_members_directory_head' );
}
/**
/**
* Member Directory Pagination
*
* @param $args
*/
add_action('um_members_directory_footer', 'um_members_directory_pagination');
function um_members_directory_pagination( $args ) {
function um_members_directory_pagination( $args ) {
extract( $args );
@@ -208,13 +213,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
}
}
add_action( 'um_members_directory_footer', 'um_members_directory_pagination' );
/**
/**
* Member Directory Display
*
* @param $args
*/
add_action('um_members_directory_display', 'um_members_directory_display');
function um_members_directory_display( $args ) {
function um_members_directory_display( $args ) {
extract( $args );
if ( isset( $args['search'] ) && $args['search'] == 1 && isset( $args['must_search'] ) && $args['must_search'] == 1 && !isset( $_REQUEST['um_search'] ) )
@@ -242,3 +250,4 @@ if ( ! defined( 'ABSPATH' ) ) exit;
include $file;
}
add_action( 'um_members_directory_display', 'um_members_directory_display' );
+19 -17
View File
@@ -3,12 +3,12 @@
if ( ! defined( 'ABSPATH' ) ) exit;
/***
*** @add a force redirect to from $_get
***/
add_action('um_after_form_fields', 'um_browser_url_redirect_to');
function um_browser_url_redirect_to( $args ) {
/**
* Add a force redirect to from $_get
*
* @param $args
*/
function um_browser_url_redirect_to( $args ) {
$url = '';
if ( ! empty( $_REQUEST['redirect_to'] ) ) {
@@ -67,22 +67,24 @@ if ( ! defined( 'ABSPATH' ) ) exit;
echo '<input type="hidden" name="redirect_to" id="redirect_to" value="' . esc_url( $url ) . '" />';
}
}
}
add_action( 'um_after_form_fields', 'um_browser_url_redirect_to' );
/***
*** @add a notice to form
***/
add_action( 'um_before_form', 'um_add_update_notice', 500 );
function um_add_update_notice( $args ) {
extract($args);
/**
* Add a notice to form
*
* @param $args
*/
function um_add_update_notice( $args ) {
extract( $args );
$output = '';
$err = '';
$success = '';
if ( isset( $_REQUEST['updated'] ) && !empty( $_REQUEST['updated'] ) && ! UM()->form()->errors ) {
switch( $_REQUEST['updated'] ) {
switch ( $_REQUEST['updated'] ) {
default:
/**
* UM hook
@@ -199,5 +201,5 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
echo $output;
}
}
add_action( 'um_before_form', 'um_add_update_notice', 500 );
+83 -62
View File
@@ -1,13 +1,12 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @process a new request
***/
add_action('um_reset_password_process_hook','um_reset_password_process_hook');
function um_reset_password_process_hook( $args ) {
/**
* Process a new request
*
* @param $args
*/
function um_reset_password_process_hook( $args ) {
$user = null;
foreach ( $_POST as $key => $val ) {
@@ -33,13 +32,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
um_reset_user();
}
}
add_action( 'um_reset_password_process_hook', 'um_reset_password_process_hook' );
/***
*** @process a change request
***/
add_action('um_change_password_process_hook','um_change_password_process_hook');
function um_change_password_process_hook( $args ) {
/**
* Process a change request
*
* @param $args
*/
function um_change_password_process_hook( $args ) {
extract( $args );
wp_set_password( $args['user_password'], $args['user_id'] );
@@ -75,15 +77,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
exit( wp_redirect( um_get_core_page('login', 'password_changed') ) );
}
add_action( 'um_change_password_process_hook','um_change_password_process_hook' );
}
/**
/**
* Overrides password changed notification
*
* @param $args
*
* @return bool
*/
add_action( 'send_password_change_email','um_send_password_change_email', 10, 1 );
function um_send_password_change_email( $args ) {
function um_send_password_change_email( $args ) {
if ( ! is_array( $args ) )
return false;
@@ -103,21 +108,27 @@ if ( ! defined( 'ABSPATH' ) ) exit;
um_reset_user();
return false;
}
}
add_action( 'send_password_change_email','um_send_password_change_email', 10, 1 );
/***
*** @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 ) {
}
/**
* This is executed after changing password
*
* @param $user_id
*/
function um_after_changing_user_password( $user_id ) {
/***
*** @Error handler: reset password
***/
add_action('um_reset_password_errors_hook','um_reset_password_errors_hook');
function um_reset_password_errors_hook( $args ) {
}
add_action( 'um_after_changing_user_password', 'um_after_changing_user_password' );
/**
* Error handler: reset password
*
* @param $args
*/
function um_reset_password_errors_hook( $args ) {
if ( $_POST[ UM()->honeypot ] != '' )
wp_die('Hello, spam bot!','ultimate-member');
@@ -172,13 +183,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
}
}
}
add_action( 'um_reset_password_errors_hook', 'um_reset_password_errors_hook' );
/***
*** @Error handler: changing password
***/
add_action('um_change_password_errors_hook','um_change_password_errors_hook');
function um_change_password_errors_hook( $args ) {
/**
* Error handler: changing password
*
* @param $args
*/
function um_change_password_errors_hook( $args ) {
if ( isset( $_POST[ UM()->honeypot ] ) && $_POST[ UM()->honeypot ] != '' ){
wp_die('Hello, spam bot!','ultimate-member');
}
@@ -235,14 +249,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
UM()->form()->add_error('confirm_user_password', __('Your passwords do not match','ultimate-member') );
}
}
}
add_action( 'um_change_password_errors_hook', 'um_change_password_errors_hook' );
/***
*** @hidden fields
***/
add_action('um_change_password_page_hidden_fields','um_change_password_page_hidden_fields');
function um_change_password_page_hidden_fields( $args ) {
/**
* Hidden fields
*
* @param $args
*/
function um_change_password_page_hidden_fields( $args ) {
?>
<input type="hidden" name="_um_password_change" id="_um_password_change" value="1" />
@@ -250,28 +266,31 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<input type="hidden" name="user_id" id="user_id" value="<?php echo $args['user_id']; ?>" />
<?php
}
add_action( 'um_change_password_page_hidden_fields', 'um_change_password_page_hidden_fields' );
}
/***
*** @hidden fields
***/
add_action('um_reset_password_page_hidden_fields','um_reset_password_page_hidden_fields');
function um_reset_password_page_hidden_fields( $args ) {
/**
* Hidden fields
*
* @param $args
*/
function um_reset_password_page_hidden_fields( $args ) {
?>
<input type="hidden" name="_um_password_reset" id="_um_password_reset" value="1" />
<?php
}
add_action( 'um_reset_password_page_hidden_fields', 'um_reset_password_page_hidden_fields' );
}
/***
*** @form content
***/
add_action('um_reset_password_form', 'um_reset_password_form');
function um_reset_password_form($args) {
/**
* Form content
*
* @param $args
*/
function um_reset_password_form( $args ) {
$fields = UM()->builtin()->get_specific_fields('password_reset_text,username_b'); ?>
@@ -312,13 +331,14 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<?php
}
}
add_action( 'um_reset_password_form', 'um_reset_password_form' );
/***
*** @change password form
***/
add_action('um_change_password_form', 'um_change_password_form');
function um_change_password_form() {
/**
* Change password form
*/
function um_change_password_form() {
$fields = UM()->builtin()->get_specific_fields('user_password'); ?>
@@ -337,4 +357,5 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<?php
}
}
add_action( 'um_change_password_form', 'um_change_password_form' );
+103 -74
View File
@@ -1,6 +1,4 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
@@ -493,25 +491,25 @@ function um_restore_default_roles( $user_id, $args, $to_update ) {
add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
/***
*** @if editing another user
***/
add_action( 'um_after_form_fields', 'um_editing_user_id_input' );
function um_editing_user_id_input( $args ) {
if (UM()->fields()->editing == 1 && UM()->fields()->set_mode == 'profile' && UM()->user()->target_id) { ?>
/**
* If editing another user
*
* @param $args
*/
function um_editing_user_id_input( $args ) {
if ( UM()->fields()->editing == 1 && UM()->fields()->set_mode == 'profile' && UM()->user()->target_id ) { ?>
<input type="hidden" name="user_id" id="user_id" value="<?php echo UM()->user()->target_id; ?>"/>
<?php
<?php }
}
add_action( 'um_after_form_fields', 'um_editing_user_id_input' );
}
}
/***
*** @meta description
***/
add_action( 'wp_head', 'um_profile_dynamic_meta_desc', 9999999 );
function um_profile_dynamic_meta_desc() {
/**
* Meta description
*/
function um_profile_dynamic_meta_desc() {
if (um_is_core_page( 'user' ) && um_get_requested_user()) {
um_fetch_user( um_get_requested_user() );
@@ -538,13 +536,16 @@ add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
<?php
}
}
}
add_action( 'wp_head', 'um_profile_dynamic_meta_desc', 9999999 );
/***
*** @profile header cover
***/
add_action( 'um_profile_header_cover_area', 'um_profile_header_cover_area', 9 );
function um_profile_header_cover_area( $args ) {
/**
* Profile header cover
*
* @param $args
*/
function um_profile_header_cover_area( $args ) {
if ($args['cover_enabled'] == 1) {
$default_cover = UM()->options()->get( 'default_cover' );
@@ -645,27 +646,33 @@ add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
}
}
}
add_action( 'um_profile_header_cover_area', 'um_profile_header_cover_area', 9 );
/***
*** @Show social links as icons below profile name
***/
add_action( 'um_after_profile_header_name_args', 'um_social_links_icons', 50 );
function um_social_links_icons( $args ) {
if (!empty( $args['show_social_links'] )) {
/**
* Show social links as icons below profile name
*
* @param $args
*/
function um_social_links_icons( $args ) {
if ( ! empty( $args['show_social_links'] ) ) {
echo '<div class="um-profile-connect um-member-connect">';
UM()->fields()->show_social_urls();
echo '</div>';
}
}
}
add_action( 'um_after_profile_header_name_args', 'um_social_links_icons', 50 );
/***
*** @profile header
***/
add_action( 'um_profile_header', 'um_profile_header', 9 );
function um_profile_header( $args ) {
/**
* Profile header
*
* @param $args
*/
function um_profile_header( $args ) {
$classes = null;
if (!$args['cover_enabled']) {
@@ -973,16 +980,22 @@ add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
</div>
<?php
}
}
add_action( 'um_profile_header', 'um_profile_header', 9 );
/***
*** @adds profile permissions to view/edit
***/
add_action( 'um_pre_profile_shortcode', 'um_pre_profile_shortcode' );
function um_pre_profile_shortcode( $args ) {
/**
* Adds profile permissions to view/edit
*
* @param $args
*/
function um_pre_profile_shortcode( $args ) {
/**
* @var $mode
*/
extract( $args );
if ($mode == 'profile' && UM()->fields()->editing == false) {
if ( $mode == 'profile' && UM()->fields()->editing == false ) {
UM()->fields()->viewing = 1;
if ( um_get_requested_user() ) {
@@ -1002,23 +1015,28 @@ add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
}
}
if ($mode == 'profile' && UM()->fields()->editing == true) {
if ( $mode == 'profile' && UM()->fields()->editing == true ) {
UM()->fields()->editing = 1;
if (um_get_requested_user()) {
if (!UM()->roles()->um_current_user_can( 'edit', um_get_requested_user() )) um_redirect_home();
if ( um_get_requested_user() ) {
if ( ! UM()->roles()->um_current_user_can( 'edit', um_get_requested_user() ) ) {
um_redirect_home();
}
um_fetch_user( um_get_requested_user() );
}
}
}
}
add_action( 'um_pre_profile_shortcode', 'um_pre_profile_shortcode' );
/***
*** @display the edit profile icon
***/
add_action( 'um_pre_header_editprofile', 'um_add_edit_icon' );
function um_add_edit_icon( $args ) {
/**
* Display the edit profile icon
*
* @param $args
*/
function um_add_edit_icon( $args ) {
$output = '';
if (!is_user_logged_in()) return; // not allowed for guests
@@ -1126,14 +1144,17 @@ add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
<?php
}
}
}
add_action( 'um_pre_header_editprofile', 'um_add_edit_icon' );
/***
*** @Show Fields
***/
add_action( 'um_main_profile_fields', 'um_add_profile_fields', 100 );
function um_add_profile_fields( $args ) {
if (UM()->fields()->editing == true) {
/**
* Show Fields
*
* @param $args
*/
function um_add_profile_fields( $args ) {
if ( UM()->fields()->editing == true ) {
echo UM()->fields()->display( 'profile', $args );
@@ -1145,15 +1166,19 @@ add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
}
}
}
add_action( 'um_main_profile_fields', 'um_add_profile_fields', 100 );
/***
*** @form processing
***/
add_action( 'um_submit_form_profile', 'um_submit_form_profile', 10 );
function um_submit_form_profile( $args ) {
if ( isset( UM()->form()->errors ) )
return false;
/**
* Form processing
*
* @param $args
*/
function um_submit_form_profile( $args ) {
if ( isset( UM()->form()->errors ) ) {
return;
}
/**
* UM hook
@@ -1175,13 +1200,16 @@ add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
* ?>
*/
do_action( 'um_user_edit_profile', $args );
}
}
add_action( 'um_submit_form_profile', 'um_submit_form_profile', 10 );
/***
*** @Show the submit button (highest priority)
***/
add_action( 'um_after_profile_fields', 'um_add_submit_button_to_profile', 1000 );
function um_add_submit_button_to_profile( $args ) {
/**
* Show the submit button (highest priority)
*
* @param $args
*/
function um_add_submit_button_to_profile( $args ) {
// DO NOT add when reviewing user's details
if (UM()->user()->preview == true && is_admin()) return;
@@ -1212,7 +1240,8 @@ add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 );
</div>
<?php
}
}
add_action( 'um_after_profile_fields', 'um_add_submit_button_to_profile', 1000 );
/**
+77 -64
View File
@@ -1,47 +1,56 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
/**
* Account automatically approved
*
* @param $user_id
* @param $args
*/
add_action('um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 2);
function um_post_registration_approved_hook($user_id, $args){
function um_post_registration_approved_hook( $user_id, $args ) {
um_fetch_user( $user_id );
UM()->user()->approve();
}
}
add_action( 'um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 2 );
/**
/**
* Account needs email validation
*
* @param $user_id
* @param $args
*/
add_action('um_post_registration_checkmail_hook', 'um_post_registration_checkmail_hook', 10, 2);
function um_post_registration_checkmail_hook($user_id, $args){
function um_post_registration_checkmail_hook( $user_id, $args ) {
um_fetch_user( $user_id );
UM()->user()->email_pending();
}
}
add_action( 'um_post_registration_checkmail_hook', 'um_post_registration_checkmail_hook', 10, 2 );
/**
/**
* Account needs admin review
*
* @param $user_id
* @param $args
*/
add_action('um_post_registration_pending_hook', 'um_post_registration_pending_hook', 10, 2);
function um_post_registration_pending_hook($user_id, $args){
function um_post_registration_pending_hook( $user_id, $args ) {
um_fetch_user( $user_id );
UM()->user()->pending();
}
}
add_action('um_post_registration_pending_hook', 'um_post_registration_pending_hook', 10, 2);
/**
/**
* After insert a new user
* run at frontend and backend
*
* @param $user_id
* @param $args
*/
function um_after_insert_user( $user_id, $args ) {
function um_after_insert_user( $user_id, $args ) {
//clear Users cached queue
UM()->user()->remove_cached_queue();
@@ -93,17 +102,17 @@ if ( ! defined( 'ABSPATH' ) ) exit;
* ?>
*/
do_action( 'um_registration_complete', $user_id, $args );
}
add_action( 'um_user_register', 'um_after_insert_user', 10, 2 );
}
add_action( 'um_user_register', 'um_after_insert_user', 10, 2 );
/**
/**
* Send notification about registration
*
* @param $user_id
* @param $args
*/
function um_send_registration_notification( $user_id, $args ) {
function um_send_registration_notification( $user_id, $args ) {
um_fetch_user( $user_id );
if ( um_user( 'status' ) != 'pending' ) {
@@ -111,17 +120,17 @@ if ( ! defined( 'ABSPATH' ) ) exit;
} else {
UM()->mail()->send( um_admin_email(), 'notification_review', array( 'admin' => true ) );
}
}
add_action( 'um_registration_complete', 'um_send_registration_notification', 10, 2 );
}
add_action( 'um_registration_complete', 'um_send_registration_notification', 10, 2 );
/**
/**
* Check user status and redirect it after registration
*
* @param $user_id
* @param $args
*/
function um_check_user_status( $user_id, $args ) {
function um_check_user_status( $user_id, $args ) {
$status = um_user( 'status' );
/**
@@ -237,17 +246,17 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
}
add_action( 'um_registration_complete', 'um_check_user_status', 100, 2 );
}
add_action( 'um_registration_complete', 'um_check_user_status', 100, 2 );
/**
/**
* Registration form submit handler
*
* @param $args
* @return bool|int|WP_Error
*/
function um_submit_form_register( $args ) {
function um_submit_form_register( $args ) {
if ( isset( UM()->form()->errors ) )
return false;
@@ -409,27 +418,24 @@ if ( ! defined( 'ABSPATH' ) ) exit;
do_action( 'um_user_register', $user_id, $args );
return $user_id;
}
add_action( 'um_submit_form_register', 'um_submit_form_register', 10 );
}
add_action( 'um_submit_form_register', 'um_submit_form_register', 10 );
/**
/**
* Register user with predefined role in options
*
* @param $args
*/
add_action( 'um_after_register_fields', 'um_add_user_role' );
function um_add_user_role( $args ) {
function um_add_user_role( $args ) {
if ( isset( $args['custom_fields']['role_select'] ) || isset( $args['custom_fields']['role_radio'] ) ) return;
$use_custom_settings = get_post_meta( $args['form_id'], '_um_register_use_custom_settings', true );
if ( ! empty( $args['role'] ) && $use_custom_settings ) {
$role = $args['role'];
} else if( ! $use_custom_settings ) {
$role = get_option( 'default_role' );
}
$role = apply_filters( 'um_registration_user_role', UM()->form()->assigned_role( UM()->form()->form_id ), $args );
if( empty( $role ) ) return;
if ( empty( $role ) ) return;
/**
* UM hook
@@ -452,18 +458,21 @@ if ( ! defined( 'ABSPATH' ) ) exit;
* }
* ?>
*/
$role = apply_filters('um_register_hidden_role_field', $role );
if( $role ){
$role = apply_filters( 'um_register_hidden_role_field', $role );
if ( $role ) {
echo '<input type="hidden" name="role" id="role" value="' . $role . '" />';
}
}
}
add_action( 'um_after_register_fields', 'um_add_user_role', 10, 1 );
/**
/**
* Show the submit button
*
* @param $args
*/
add_action('um_after_register_fields', 'um_add_submit_button_to_register', 1000);
function um_add_submit_button_to_register($args){
function um_add_submit_button_to_register( $args ) {
// DO NOT add when reviewing user's details
if ( isset( UM()->user()->preview ) && UM()->user()->preview == true && is_admin() ) return;
@@ -540,9 +549,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
* }
* ?>
*/
$secondary_btn_url = apply_filters('um_register_form_button_two_url', $secondary_btn_url, $args );
?>
$secondary_btn_url = apply_filters('um_register_form_button_two_url', $secondary_btn_url, $args ); ?>
<div class="um-col-alt">
@@ -562,23 +569,28 @@ if ( ! defined( 'ABSPATH' ) ) exit;
</div>
<?php
}
}
add_action( 'um_after_register_fields', 'um_add_submit_button_to_register', 1000 );
/**
/**
* Show Fields
*
* @param $args
*/
add_action('um_main_register_fields', 'um_add_register_fields', 100);
function um_add_register_fields($args){
function um_add_register_fields( $args ){
echo UM()->fields()->display( 'register', $args );
}
}
add_action( 'um_main_register_fields', 'um_add_register_fields', 100 );
/**
/**
* Saving files to register a new user, if there are fields with files
*
* @param $user_id
* @param $args
*/
add_action( 'um_registration_set_extra_data', 'um_registration_save_files', 10, 2 );
function um_registration_save_files( $user_id, $args ) {
function um_registration_save_files( $user_id, $args ) {
if ( empty( $args['custom_fields'] ) )
return;
@@ -673,9 +685,11 @@ if ( ! defined( 'ABSPATH' ) ) exit;
*/
do_action( 'um_after_user_upload', $user_id, $files );
}
}
}
add_action( 'um_registration_set_extra_data', 'um_registration_save_files', 10, 2 );
/**
/**
* Update user Full Name
*
* @profile name update
@@ -683,7 +697,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
* @param $user_id
* @param $args
*/
function um_registration_set_profile_full_name( $user_id, $args ) {
function um_registration_set_profile_full_name( $user_id, $args ) {
/**
* UM hook
*
@@ -705,6 +719,5 @@ if ( ! defined( 'ABSPATH' ) ) exit;
* ?>
*/
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 );
}
add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_name', 10, 2 );
+10 -11
View File
@@ -1,13 +1,13 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @profile name update
***/
add_action( 'um_update_profile_full_name', 'um_update_profile_full_name', 10, 2 );
function um_update_profile_full_name( $user_id, $changes ) {
/**
* Profile name update
*
* @param $user_id
* @param $changes
*/
function um_update_profile_full_name( $user_id, $changes ) {
// Sync display name changes
$option = UM()->options()->get( 'display_name' );
@@ -52,7 +52,6 @@ if ( ! defined( 'ABSPATH' ) ) exit;
wp_die( '<pre>' . var_export( array( 'message' => $return->get_error_message(), 'dump' => $arr_user, 'changes' => $changes ), true ) . '</pre>' );
}
}
if ( isset( $changes['first_name'] ) && isset( $changes['last_name'] ) ) {
@@ -62,9 +61,9 @@ if ( ! defined( 'ABSPATH' ) ) exit;
update_user_meta( UM()->user()->id, 'full_name', $full_name );
}
// regenerate slug
UM()->user()->generate_profile_slug( $user_id );
}
}
add_action( 'um_update_profile_full_name', 'um_update_profile_full_name', 10, 2 );
+12 -16
View File
@@ -1,17 +1,14 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
/**
* Account secure fields
* @param array $fields
* @param string $tab_key
* @return array
* @uses um_account_secure_fields
*/
add_filter('um_account_secure_fields','um_account_secure_fields', 10, 2);
function um_account_secure_fields( $fields, $tab_key ){
function um_account_secure_fields( $fields, $tab_key ) {
/**
* UM hook
*
@@ -37,30 +34,29 @@ if ( ! defined( 'ABSPATH' ) ) exit;
if( ! $secure ) return $fields;
if( isset( UM()->account()->register_fields ) && ! isset( UM()->account()->register_fields[ $tab_key ] ) ){
UM()->account()->register_fields[ $tab_key ] = $fields;
}
return $fields;
}
}
add_filter( 'um_account_secure_fields', 'um_account_secure_fields', 10, 2 );
/**
/**
* Disables first and last name fields in account page
* @param array $fields
* @return array
* @uses um_get_field__first_name, um_get_field__last_name
*/
add_filter("um_get_field__first_name","um_account_disable_name_fields", 10 ,1 );
add_filter("um_get_field__last_name","um_account_disable_name_fields", 10 ,1 );
function um_account_disable_name_fields( $fields ){
function um_account_disable_name_fields( $fields ){
if( ! UM()->options()->get( "account_name_disable" ) ) return $fields;
if( um_is_core_page("account") ){
if ( um_is_core_page("account") ) {
$fields['disabled'] = 'disabled="disabled"';
}
return $fields;
}
}
add_filter( "um_get_field__first_name","um_account_disable_name_fields", 10 ,1 );
add_filter( "um_get_field__last_name","um_account_disable_name_fields", 10 ,1 );
+17 -16
View File
@@ -1,18 +1,21 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @Do not apply to backend default avatars
***/
add_filter('avatar_defaults', 'um_avatar_defaults', 99999 );
function um_avatar_defaults($avatar_defaults) {
remove_filter('get_avatar', 'um_get_avatar', 99999, 5);
/**
* Do not apply to backend default avatars
*
* @param $avatar_defaults
*
* @return mixed
*/
function um_avatar_defaults( $avatar_defaults ) {
remove_filter( 'get_avatar', 'um_get_avatar', 99999 );
return $avatar_defaults;
}
}
add_filter( 'avatar_defaults', 'um_avatar_defaults', 99999 );
/**
/**
* Get user UM avatars
* @param string $avatar
* @param string $id_or_email
@@ -23,8 +26,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
* @hooks filter `get_avatar`
* @return string returns avatar in image html elements
*/
add_filter('get_avatar', 'um_get_avatar', 99999, 5);
function um_get_avatar($avatar = '', $id_or_email='', $size = '96', $avatar_class = '', $default = '', $alt = '') {
function um_get_avatar( $avatar = '', $id_or_email='', $size = '96', $avatar_class = '', $default = '', $alt = '' ) {
if ( is_numeric($id_or_email) )
$user_id = (int) $id_or_email;
@@ -98,6 +100,5 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $avatar;
}
}
add_filter( 'get_avatar', 'um_get_avatar', 99999, 5 );
+13 -10
View File
@@ -1,13 +1,16 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @Control comment author display
***/
add_filter('get_comment_author_link', 'um_comment_link_to_profile', 10000, 3 );
function um_comment_link_to_profile( $return, $author, $comment_ID ) {
/**
* Control comment author display
*
* @param $return
* @param $author
* @param $comment_ID
*
* @return string
*/
function um_comment_link_to_profile( $return, $author, $comment_ID ) {
$comment = get_comment( $comment_ID );
@@ -29,6 +32,6 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $return;
}
}
add_filter('get_comment_author_link', 'um_comment_link_to_profile', 10000, 3 );
+229 -145
View File
@@ -1,29 +1,37 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @field is required?
***/
add_filter('um_edit_label_all_fields', 'um_edit_label_all_fields', 10, 2);
function um_edit_label_all_fields( $label, $data ) {
/**
* Field is required?
*
* @param $label
* @param $data
*
* @return string
*/
function um_edit_label_all_fields( $label, $data ) {
$asterisk = UM()->options()->get( 'form_asterisk' );
if ( $asterisk && isset( $data['required'] ) && $data['required'] == 1 )
$label = $label . '<span class="um-req" title="'.__('Required','ultimate-member').'">*</span>';
return $label;
}
}
add_filter( 'um_edit_label_all_fields', 'um_edit_label_all_fields', 10, 2 );
/***
*** @outputs a soundcloud track
***/
add_filter('um_profile_field_filter_hook__soundcloud_track', 'um_profile_field_filter_hook__soundcloud_track', 99, 2);
function um_profile_field_filter_hook__soundcloud_track( $value, $data ) {
/**
* Outputs a soundcloud track
*
* @param $value
* @param $data
*
* @return string|void
*/
function um_profile_field_filter_hook__soundcloud_track( $value, $data ) {
if ( !is_numeric( $value ) ) {
return __('Invalid soundcloud track ID','ultimate-member');
return __( 'Invalid soundcloud track ID', 'ultimate-member' );
}
$value = '<div class="um-soundcloud">
@@ -31,13 +39,19 @@ if ( ! defined( 'ABSPATH' ) ) exit;
</div>';
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__soundcloud_track', 'um_profile_field_filter_hook__soundcloud_track', 99, 2 );
/***
*** @outputs a youtube video
***/
add_filter('um_profile_field_filter_hook__youtube_video', 'um_profile_field_filter_hook__youtube_video', 99, 2);
function um_profile_field_filter_hook__youtube_video( $value, $data ) {
/**
* Outputs a youtube video
*
* @param $value
* @param $data
*
* @return bool|string
*/
function um_profile_field_filter_hook__youtube_video( $value, $data ) {
if( empty( $value ) ){
return '';
}
@@ -48,13 +62,19 @@ if ( ! defined( 'ABSPATH' ) ) exit;
return $value;
}
add_filter( 'um_profile_field_filter_hook__youtube_video', 'um_profile_field_filter_hook__youtube_video', 99, 2 );
/***
*** @outputs a vimeo video
***/
add_filter('um_profile_field_filter_hook__vimeo_video', 'um_profile_field_filter_hook__vimeo_video', 99, 2);
function um_profile_field_filter_hook__vimeo_video( $value, $data ) {
if( empty( $value ) ){
/**
* Outputs a vimeo video
*
* @param $value
* @param $data
*
* @return int|string
*/
function um_profile_field_filter_hook__vimeo_video( $value, $data ) {
if ( empty( $value ) ) {
return '';
}
@@ -63,46 +83,69 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<iframe src="https://player.vimeo.com/video/'. $value . '" width="600" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>';
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__vimeo_video', 'um_profile_field_filter_hook__vimeo_video', 99, 2 );
/***
*** @outputs a google map
***/
add_filter('um_profile_field_filter_hook__googlemap', 'um_profile_field_filter_hook__googlemap', 99, 2);
function um_profile_field_filter_hook__googlemap( $value, $data ) {
/**
* Outputs a google map
*
* @param $value
* @param $data
*
* @return string
*/
function um_profile_field_filter_hook__googlemap( $value, $data ) {
$value = '<div class="um-googlemap">
<iframe width="600" height="450" frameborder="0" style="border:0" src="https://maps.google.it/maps?q=' . urlencode( $value ) . '&output=embed"></iframe>
</div>';
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__googlemap', 'um_profile_field_filter_hook__googlemap', 99, 2 );
/***
*** @user's registration date
***/
add_filter('um_profile_field_filter_hook__user_registered', 'um_profile_field_filter_hook__user_registered', 99, 2);
function um_profile_field_filter_hook__user_registered( $value, $data ) {
/**
* User's registration date
*
* @param $value
* @param $data
*
* @return false|int|string
*/
function um_profile_field_filter_hook__user_registered( $value, $data ) {
$value = strtotime($value);
$value = sprintf(__('Joined %s','ultimate-member'), date_i18n('F d, Y', $value) );
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__user_registered', 'um_profile_field_filter_hook__user_registered', 99, 2 );
/***
*** @last login date
***/
add_filter('um_profile_field_filter_hook__last_login', 'um_profile_field_filter_hook__last_login', 99, 2);
add_filter('um_profile_field_filter_hook___um_last_login', 'um_profile_field_filter_hook__last_login', 99, 2);
function um_profile_field_filter_hook__last_login( $value, $data ) {
/**
* Last login date
*
* @param $value
* @param $data
*
* @return string
*/
function um_profile_field_filter_hook__last_login( $value, $data ) {
$value = sprintf( __('Last login: %s','ultimate-member'), um_user_last_login( um_user('ID') ) );
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__last_login', 'um_profile_field_filter_hook__last_login', 99, 2 );
add_filter( 'um_profile_field_filter_hook___um_last_login', 'um_profile_field_filter_hook__last_login', 99, 2 );
/***
*** @urls in textarea
***/
add_filter('um_profile_field_filter_hook__textarea', 'um_profile_field_filter_hook__textarea', 99, 2);
function um_profile_field_filter_hook__textarea( $value, $data ) {
/**
* URLs in textarea
*
* @param $value
* @param $data
*
* @return mixed|string|void
*/
function um_profile_field_filter_hook__textarea( $value, $data ) {
if ( isset( $data ) && isset( $data['html'] ) && $data['html'] == 1 )
return $value;
@@ -112,7 +155,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
$value = wpautop($value);
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__textarea', 'um_profile_field_filter_hook__textarea', 99, 2 );
/***
@@ -132,23 +176,33 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}*/
/***
*** @time
***/
add_filter('um_profile_field_filter_hook__time', 'um_profile_field_filter_hook__time', 99, 2);
function um_profile_field_filter_hook__time( $value, $data ) {
/**
* Time field
*
* @param $value
* @param $data
*
* @return mixed|string
*/
function um_profile_field_filter_hook__time( $value, $data ) {
$value = UM()->datetime()->format( $value, $data['format'] );
$value = str_replace('am', 'a.m.', $value );
$value = str_replace('pm', 'p.m.', $value );
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__time', 'um_profile_field_filter_hook__time', 99, 2 );
/***
*** @date
***/
add_filter('um_profile_field_filter_hook__date', 'um_profile_field_filter_hook__date', 99, 2);
function um_profile_field_filter_hook__date( $value, $data ) {
/**
* Date field
*
* @param $value
* @param $data
*
* @return string
*/
function um_profile_field_filter_hook__date( $value, $data ) {
if ( $data['pretty_format'] == 1 ) {
$value = UM()->datetime()->get_age( $value );
} else {
@@ -156,13 +210,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__date', 'um_profile_field_filter_hook__date', 99, 2 );
/***
*** @file
***/
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 ) {
/**
* File field
* @param $value
* @param $data
*
* @return string|void
*/
function um_profile_field_filter_hook__file( $value, $data ) {
$uri = um_user_uploads_uri() . $value;
$extension = pathinfo( $uri, PATHINFO_EXTENSION);
@@ -180,13 +239,19 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__file', 'um_profile_field_filter_hook__file', 99, 2 );
/***
*** @image
***/
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 ) {
/**
* Image field
*
* @param $value
* @param $data
*
* @return string
*/
function um_profile_field_filter_hook__image( $value, $data ) {
$uri = um_user_uploads_uri() . $value;
$title = ( isset( $data['title'] ) ) ? $data['title'] : __('Untitled photo');
@@ -201,13 +266,19 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__image', 'um_profile_field_filter_hook__image', 99, 2 );
/***
*** @global
***/
add_filter('um_profile_field_filter_hook__', 'um_profile_field_filter_hook__', 99, 3 );
function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
/**
* Global sanitize
*
* @param $value
* @param $data
* @param string $type
*
* @return string
*/
function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
if ( !$value ) return '';
if ( ( isset( $data['validate'] ) && $data['validate'] != '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
@@ -259,13 +330,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
//$value = UM()->shortcodes()->emotize( $value );
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__', 'um_profile_field_filter_hook__', 99, 3 );
/***
*** @get form fields
***/
add_filter('um_get_form_fields', 'um_get_form_fields', 99);
function um_get_form_fields( $array ) {
/**
* Get form fields
*
* @param $array
*
* @return mixed|string
*/
function um_get_form_fields( $array ) {
$form_id = (isset ( UM()->fields()->set_id ) ) ? UM()->fields()->set_id : null;
$mode = (isset( UM()->fields()->set_mode ) ) ? UM()->fields()->set_mode : null;
@@ -278,17 +354,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
return $array;
}
}
add_filter( 'um_get_form_fields', 'um_get_form_fields', 99 );
/**
/**
* Validate conditional logic
*
* @param $array
* @param $fields
* @return mixed
*/
function um_get_custom_field_array( $array, $fields ) {
function um_get_custom_field_array( $array, $fields ) {
if ( isset( $array['conditions'] ) ) {
for ( $a = 0; $a < count( $array['conditions'] ); $a++ ) {
@@ -311,19 +388,20 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $array;
}
add_filter( 'um_get_custom_field_array', 'um_get_custom_field_array', 99, 2 );
}
add_filter( 'um_get_custom_field_array', 'um_get_custom_field_array', 99, 2 );
/**
/**
* Force fields to use UTF-8 encoding
*
* @param mixed $value
* @param array $data
* @param string $type
*
* @return mixed
* @uses hook filter: um_profile_field_filter_hook__
*/
add_filter('um_profile_field_filter_hook__','um_force_utf8_fields', 9, 3 );
function um_force_utf8_fields( $value, $data, $type = '' ) {
function um_force_utf8_fields( $value, $data, $type = '' ) {
if( ! UM()->options()->get('um_force_utf8_strings') )
return $value;
@@ -333,53 +411,54 @@ if ( ! defined( 'ABSPATH' ) ) exit;
return $value;
}
add_filter('um_profile_field_filter_hook__','um_force_utf8_fields', 9, 3 );
/**
/**
* Filter profile data value
* @param mixed $value
* @return mixed
* @uses hook filter: um_is_selected_filter_value
*/
add_filter('um_is_selected_filter_value','um_is_selected_filter_value',1,9);
add_filter('um_select_dropdown_dynamic_option_value','um_is_selected_filter_value',1,10);
function um_is_selected_filter_value( $value ){
function um_is_selected_filter_value( $value ) {
if ( ! UM()->options()->get('um_force_utf8_strings') )
return $value;
$value = um_force_utf8_string( $value );
return $value;
}
}
add_filter( 'um_is_selected_filter_value','um_is_selected_filter_value', 1, 9 );
add_filter( 'um_select_dropdown_dynamic_option_value','um_is_selected_filter_value', 1, 10 );
/**
/**
* Filter select dropdown to use UTF-8 encoding
*
* @param array $options
* @param array $data
* @return $options
* @return array
* @uses hook filter: um_select_dropdown_dynamic_options
*/
add_filter('um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_options_to_utf8',2,10);
function um_select_dropdown_dynamic_options_to_utf8( $options, $data ){
function um_select_dropdown_dynamic_options_to_utf8( $options, $data ){
if ( ! UM()->options()->get( 'um_force_utf8_strings' ) )
return $options;
foreach ( $options as $key => $value ) {
$options[ $key ] = um_force_utf8_string( $value );
}
return $options;
}
}
add_filter( 'um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_options_to_utf8', 2, 10 );
/**
/**
* Filter non-UTF8 strings
* @param string $value
* @return string
* @uses hook filter: um_field_non_utf8_value
*/
add_filter( 'um_field_non_utf8_value', 'um_field_non_utf8_value' );
function um_field_non_utf8_value( $value ) {
function um_field_non_utf8_value( $value ) {
if ( function_exists( 'mb_detect_encoding' ) ) {
$encoding = mb_detect_encoding( $value, 'utf-8, iso-8859-1, ascii', true );
@@ -389,19 +468,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $value;
}
}
add_filter( 'um_field_non_utf8_value', 'um_field_non_utf8_value' );
/**
/**
* Returns dropdown/multi-select options from a callback function
* @param $options array
* @param $data array
* @return $options array
* @return array
* @uses hook filter: um_select_dropdown_dynamic_options, um_multiselect_options
*/
add_filter('um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_callback_options', 10, 2);
add_filter('um_multiselect_options','um_select_dropdown_dynamic_callback_options', 10, 2);
function um_select_dropdown_dynamic_callback_options( $options, $data ){
function um_select_dropdown_dynamic_callback_options( $options, $data ) {
if( isset( $data['custom_dropdown_options_source'] ) && ! empty( $data['custom_dropdown_options_source'] ) ){
@@ -411,42 +489,45 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $options;
}
}
add_filter( 'um_select_dropdown_dynamic_options','um_select_dropdown_dynamic_callback_options', 10, 2 );
add_filter( 'um_multiselect_options','um_select_dropdown_dynamic_callback_options', 10, 2 );
/**
*
/**
* Pair dropdown/multi-select options from a callback function
*
* @param $value string
* @param $type string
* @param $data array
* @return $value string
* @return string
* @uses hook filter: um_profile_field_filter_hook__
*/
add_filter('um_profile_field_filter_hook__select','um_option_match_callback_view_field', 10, 2);
add_filter('um_profile_field_filter_hook__multiselect','um_option_match_callback_view_field', 10, 2);
add_filter('um_field_select_default_value','um_option_match_callback_view_field', 10, 2);
add_filter('um_field_multiselect_default_value','um_option_match_callback_view_field', 10, 2);
function um_option_match_callback_view_field( $value, $data ){
function um_option_match_callback_view_field( $value, $data ) {
if( ! empty( $data['custom_dropdown_options_source'] ) ){
return UM()->fields()->get_option_value_from_callback( $value, $data, $data['type'] );
}
return $value;
}
}
add_filter('um_profile_field_filter_hook__select','um_option_match_callback_view_field', 10, 2);
add_filter('um_profile_field_filter_hook__multiselect','um_option_match_callback_view_field', 10, 2);
add_filter('um_field_select_default_value','um_option_match_callback_view_field', 10, 2);
add_filter('um_field_multiselect_default_value','um_option_match_callback_view_field', 10, 2);
/**
/**
* Apply textdomain in select/multi-select options
*
* @param $value string
* @param $type string
* @param $data array
* @return $value string
* @return string
* @uses hook filters: um_profile_field_filter_hook__select, um_profile_field_filter_hook__multiselect
*/
add_filter('um_profile_field_filter_hook__select','um_profile_field__select_translate', 10, 2);
add_filter('um_profile_field_filter_hook__multiselect','um_profile_field__select_translate', 10, 2);
function um_profile_field__select_translate( $value, $data ){
if( empty( $value ) ) return $value;
function um_profile_field__select_translate( $value, $data ) {
if ( empty( $value ) ) return $value;
$options = explode(", ", $value );
$arr_options = array();
@@ -459,7 +540,9 @@ if ( ! defined( 'ABSPATH' ) ) exit;
$value = implode(", ", $arr_options);
return $value;
}
}
add_filter( 'um_profile_field_filter_hook__select','um_profile_field__select_translate', 10, 2 );
add_filter( 'um_profile_field_filter_hook__multiselect','um_profile_field__select_translate', 10, 2 );
/**
@@ -488,7 +571,8 @@ function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) {
}
add_filter( 'um_profile_field_filter_hook__','um_profile_field_filter_xss_validation', 10, 3 );
/**
/**
* add role_select and role_radio to the $post_form
* It is necessary for that if on these fields the conditional logic
* @param $post_form array
@@ -497,7 +581,7 @@ add_filter( 'um_profile_field_filter_hook__','um_profile_field_filter_xss_valida
* @return $post_form
* @uses hook filters: um_submit_form_data
*/
function um_submit_form_data_role_fields( $post_form, $mode ) {
function um_submit_form_data_role_fields( $post_form, $mode ) {
$custom_fields = unserialize( $post_form['custom_fields'] );
if ( ! empty( $post_form['role'] ) && array_key_exists( 'role_select', $custom_fields ) ) {
$post_form['role_select'] = $post_form['role'];
@@ -507,11 +591,11 @@ add_filter( 'um_profile_field_filter_hook__','um_profile_field_filter_xss_valida
}
return $post_form;
}
add_filter( 'um_submit_form_data', 'um_submit_form_data_role_fields', 10, 2 );
}
add_filter( 'um_submit_form_data', 'um_submit_form_data_role_fields', 10, 2 );
/**
/**
* Cleaning on XSS injection for url editing field
* @param $value string
* @param $key string
@@ -519,8 +603,8 @@ add_filter( 'um_profile_field_filter_hook__','um_profile_field_filter_xss_valida
* @return string $value
* @uses hook filters: um_edit_url_field_value
*/
function um_edit_url_field_value( $value, $key ) {
function um_edit_url_field_value( $value, $key ) {
$value = esc_attr( $value );
return $value;
}
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
}
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
+10 -8
View File
@@ -1,13 +1,13 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @Support multisite
***/
add_filter('um_upload_basedir_filter','um_multisite_urls_support', 99 );
add_filter('um_upload_baseurl_filter','um_multisite_urls_support', 99 );
/**
* Support multisite
*
* @param $dir
*
* @return string
*/
function um_multisite_urls_support( $dir ) {
if ( is_multisite() ) { // Need to the work
@@ -67,3 +67,5 @@ function um_multisite_urls_support( $dir ) {
return $dir;
}
add_filter( 'um_upload_basedir_filter', 'um_multisite_urls_support', 99 );
add_filter( 'um_upload_baseurl_filter', 'um_multisite_urls_support', 99 );
+48 -29
View File
@@ -1,14 +1,14 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @filter to allow whitelisted IP to access the wp-admin login
***/
add_filter('um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access');
function um_whitelisted_wpadmin_access( $allowed ) {
/**
* Filter to allow whitelisted IP to access the wp-admin login
*
* @param $allowed
*
* @return int
*/
function um_whitelisted_wpadmin_access( $allowed ) {
$ips = UM()->options()->get( 'wpadmin_allow_ips' );
if ( !$ips )
@@ -21,14 +21,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
$allowed = 1;
return $allowed;
}
add_filter( 'um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access' );
}
/***
*** @filter to customize errors
***/
add_filter('login_message', 'um_custom_wp_err_messages');
function um_custom_wp_err_messages( $message ) {
/**
* Filter to customize errors
*
* @param $message
*
* @return string
*/
function um_custom_wp_err_messages( $message ) {
if ( isset( $_REQUEST['err'] ) && !empty( $_REQUEST['err'] ) ) {
switch( $_REQUEST['err'] ) {
@@ -46,13 +50,20 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $message;
}
}
add_filter( 'login_message', 'um_custom_wp_err_messages' );
/***
*** @check for blocked ip
***/
add_filter('authenticate', 'um_wp_form_errors_hook_ip_test', 10, 3);
function um_wp_form_errors_hook_ip_test( $user, $username, $password ) {
/**
* Check for blocked ip
*
* @param $user
* @param $username
* @param $password
*
* @return mixed
*/
function um_wp_form_errors_hook_ip_test( $user, $username, $password ) {
if ( ! empty( $username ) ) {
/**
* UM hook
@@ -98,15 +109,22 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $user;
}
}
add_filter( 'authenticate', 'um_wp_form_errors_hook_ip_test', 10, 3 );
/***
*** @login checks thru the wordpress admin login
***/
add_filter('authenticate', 'um_wp_form_errors_hook_logincheck', 50, 3);
function um_wp_form_errors_hook_logincheck( $user, $username, $password ) {
do_action('wp_authenticate_username_password_before', $user, $username, $password );
/**
* Login checks thru the wordpress admin login
*
* @param $user
* @param $username
* @param $password
*
* @return WP_Error|WP_User
*/
function um_wp_form_errors_hook_logincheck( $user, $username, $password ) {
do_action( 'wp_authenticate_username_password_before', $user, $username, $password );
if ( isset( $user->ID ) ) {
@@ -132,4 +150,5 @@ if ( ! defined( 'ABSPATH' ) ) exit;
return wp_authenticate_username_password( $user, $username, $password );
}
}
add_filter( 'authenticate', 'um_wp_form_errors_hook_logincheck', 50, 3 );
+86 -60
View File
@@ -1,20 +1,15 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @Members Filter Hooks
***/
add_filter( 'um_prepare_user_query_args', 'um_prepare_user_query_args', 10, 2 );
add_filter( 'um_prepare_user_query_args', 'um_add_search_to_query', 50, 2 );
add_filter( 'um_prepare_user_query_args', 'um_search_usernames_emails', 51, 2 );
add_filter( 'um_prepare_user_query_args', 'um_remove_special_users_from_list', 99, 2 );
/***
*** @WP API user search
***/
function um_search_usernames_emails( $query_args, $args ) {
/**
* WP API user search
*
* @param $query_args
* @param $args
*
* @return mixed
*/
function um_search_usernames_emails( $query_args, $args ) {
extract( $args );
$query = UM()->permalinks()->get_query_array();
@@ -31,9 +26,11 @@ if ( ! defined( 'ABSPATH' ) ) exit;
$query_args['search_columns'] = $arr_columns;
return $query_args;
}
}
add_filter( 'um_prepare_user_query_args', 'um_search_usernames_emails', 51, 2 );
/**
/**
* Remove users we do not need to show in directory
*
* @param $query_args
@@ -41,7 +38,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
*
* @return mixed
*/
function um_remove_special_users_from_list( $query_args, $args ) {
function um_remove_special_users_from_list( $query_args, $args ) {
extract( $args );
$query_args['meta_query']['relation'] = 'AND';
@@ -96,12 +93,19 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $query_args;
}
}
add_filter( 'um_prepare_user_query_args', 'um_remove_special_users_from_list', 99, 2 );
/***
*** @adds search parameters
***/
function um_add_search_to_query( $query_args, $args ){
/**
* Adds search parameters
*
* @param $query_args
* @param $args
*
* @return mixed|void
*/
function um_add_search_to_query( $query_args, $args ){
extract( $args );
if ( isset( $_REQUEST['um_search'] ) ) {
@@ -212,12 +216,19 @@ if ( ! defined( 'ABSPATH' ) ) exit;
return $query_args;
}
}
add_filter( 'um_prepare_user_query_args', 'um_add_search_to_query', 50, 2 );
/***
*** @adds main parameters
***/
function um_prepare_user_query_args( $query_args, $args ) {
/**
* Adds main parameters
*
* @param $query_args
* @param $args
*
* @return mixed
*/
function um_prepare_user_query_args( $query_args, $args ) {
extract( $args );
$query_args['fields'] = 'ID';
@@ -360,27 +371,37 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $query_args;
}
}
add_filter( 'um_prepare_user_query_args', 'um_prepare_user_query_args', 10, 2 );
/***
*** @sorting by last login date
***/
add_filter('um_modify_sortby_parameter', 'um_sortby_last_login', 100, 2 );
function um_sortby_last_login( $query_args, $sortby ) {
/**
* Sorting by last login date
*
* @param $query_args
* @param $sortby
*
* @return mixed
*/
function um_sortby_last_login( $query_args, $sortby ) {
if ( $sortby == 'last_login' ) {
$query_args['orderby'] = 'meta_value_num';
$query_args['order'] = 'desc';
$query_args['meta_key'] = '_um_last_login';
}
return $query_args;
}
}
add_filter( 'um_modify_sortby_parameter', 'um_sortby_last_login', 100, 2 );
/***
*** @sorting random
***/
add_filter('pre_user_query','um_modify_sortby_randomly');
function um_modify_sortby_randomly( $query ){
/**
* Sorting random
*
* @param $query
*
* @return mixed
*/
function um_modify_sortby_randomly( $query ) {
if( um_is_session_started() === false ){
@session_start();
}
@@ -409,14 +430,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $query;
}
}
add_filter( 'pre_user_query','um_modify_sortby_randomly' );
/***
*** @hook in the member results array
***/
add_filter('um_prepare_user_results_array', 'um_prepare_user_results_array', 50, 2);
function um_prepare_user_results_array($result){
/**
* Hook in the member results array
*
* @param $result
*
* @return mixed
*/
function um_prepare_user_results_array( $result ) {
if ( empty( $result['users_per_page'] ) ) {
$result['no_users'] = 1;
} else {
@@ -424,15 +449,17 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $result;
}
}
add_filter( 'um_prepare_user_results_array', 'um_prepare_user_results_array', 50, 2 );
/**
/**
* Retrieves search filter options from a callback
*
* @param $atts array
* @return $atts array
* @return array
*/
add_filter('um_search_select_fields','um_search_select_fields');
function um_search_select_fields( $atts ){
function um_search_select_fields( $atts ) {
if( isset( $atts['custom_dropdown_options_source'] ) && ! empty( $atts['custom_dropdown_options_source'] ) ){
$atts['custom'] = true;
@@ -443,20 +470,19 @@ if ( ! defined( 'ABSPATH' ) ) exit;
$atts['label'] = strip_tags( $atts['label'] );
}
return $atts;
}
}
add_filter( 'um_search_select_fields', 'um_search_select_fields' );
/**
/**
* Filter gender query argument
*
* @param array $field_query
* @return array
*/
add_filter('um_query_args_gender__filter','um_query_args_gender__filter');
function um_query_args_gender__filter( $field_query ){
function um_query_args_gender__filter( $field_query ) {
unset( $field_query[1] );
return $field_query;
}
}
add_filter( 'um_query_args_gender__filter', 'um_query_args_gender__filter' );
+11 -9
View File
@@ -1,13 +1,15 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @formats numbers nicely
***/
add_filter('um_pretty_number_formatting', 'um_pretty_number_formatting');
function um_pretty_number_formatting( $count ) {
/**
* Formats numbers nicely
*
* @param $count
*
* @return string
*/
function um_pretty_number_formatting( $count ) {
$count = (int)$count;
return number_format( $count );
}
}
add_filter( 'um_pretty_number_formatting', 'um_pretty_number_formatting' );
+11 -9
View File
@@ -1,6 +1,4 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
@@ -26,12 +24,16 @@ function um_add_custom_message_to_menu( $items, $args ) {
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 );
/**
* Conditional menu items
*
* @param $items
* @param $menu
* @param $args
*
* @return mixed
*/
function um_conditional_nav_menu( $items, $menu, $args ) {
$hide_children_of = array();
@@ -111,5 +113,5 @@ if ( ! is_admin() ) {
return $items;
}
add_filter( 'wp_get_nav_menu_items', 'um_conditional_nav_menu', 9999, 3 );
}
+45 -34
View File
@@ -1,19 +1,16 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @dynamic profile page title
***/
add_filter('wp_title', 'um_dynamic_user_profile_pagetitle', 100000, 2 );
add_filter('pre_get_document_title', 'um_dynamic_user_profile_pagetitle', 100000, 2 );
/**
* fix for plugin "The SEO Framework"
/**
* Fix for plugin "The SEO Framework", dynamic profile page title
* @link https://ru.wordpress.org/plugins/autodescription/
*
* @param $title
* @param string $sep
*
* @return mixed|string
*/
add_filter('the_seo_framework_pro_add_title', 'um_dynamic_user_profile_pagetitle', 100000, 2 );
function um_dynamic_user_profile_pagetitle( $title, $sep = '' ) {
function um_dynamic_user_profile_pagetitle( $title, $sep = '' ) {
$profile_title = UM()->options()->get( 'profile_title' );
@@ -30,13 +27,21 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $title;
}
}
add_filter('the_seo_framework_pro_add_title', 'um_dynamic_user_profile_pagetitle', 100000, 2 );
add_filter('wp_title', 'um_dynamic_user_profile_pagetitle', 100000, 2 );
add_filter('pre_get_document_title', 'um_dynamic_user_profile_pagetitle', 100000, 2 );
/***
*** @try and modify the page title in page
***/
add_filter('the_title', 'um_dynamic_user_profile_title', 100000, 2 );
function um_dynamic_user_profile_title( $title, $id = '' ) {
/**
* Try and modify the page title in page
*
* @param $title
* @param string $id
*
* @return string
*/
function um_dynamic_user_profile_title( $title, $id = '' ) {
if( is_admin() ){
return $title;
@@ -56,15 +61,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return (strlen($title)!==strlen(utf8_decode($title))) ? $title : utf8_encode($title);
}
}
add_filter( 'the_title', 'um_dynamic_user_profile_title', 100000, 2 );
/***
*** @Add cover photo label of file size limit
***/
add_filter('um_predefined_fields_hook','um_change_profile_cover_photo_label',10,1);
function um_change_profile_cover_photo_label( $args ){
/**
* Add cover photo label of file size limit
*
* @param $args
*
* @return mixed
*/
function um_change_profile_cover_photo_label( $args ){
$max_size = UM()->files()->format_bytes( $args['cover_photo']['max_size'] );
list( $file_size, $unit ) = explode(' ', $max_size );
@@ -75,20 +83,23 @@ if ( ! defined( 'ABSPATH' ) ) exit;
}
return $args;
}
add_filter( 'um_predefined_fields_hook', 'um_change_profile_cover_photo_label', 10, 1 );
/***
*** @Add profile photo label of file size limit
***/
add_filter('um_predefined_fields_hook','um_change_profile_photo_label',10,1);
function um_change_profile_photo_label( $args ){
/**
* Add profile photo label of file size limit
*
* @param $args
*
* @return mixed
*/
function um_change_profile_photo_label( $args ) {
$max_size = UM()->files()->format_bytes( $args['profile_photo']['max_size'] );
list( $file_size, $unit ) = explode(' ', $max_size );
if( $file_size >= 999999999 ){
}else{
if ( $file_size < 999999999 ) {
$args['profile_photo']['upload_text'] .= '<small class=\'um-max-filesize\'>( '.__('max','ultimate-member').': <span>'.$file_size.$unit.'</span> )</small>';
}
return $args;
}
}
add_filter( 'um_predefined_fields_hook', 'um_change_profile_photo_label', 10, 1 );
+10 -8
View File
@@ -1,12 +1,13 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/***
*** @Main admin user actions
***/
add_filter('um_admin_user_actions_hook', 'um_admin_user_actions_hook', 1);
/**
* Main admin user actions
*
* @param $actions
*
* @return null
*/
function um_admin_user_actions_hook( $actions ) {
$actions = null;
@@ -54,6 +55,7 @@ function um_admin_user_actions_hook( $actions ) {
return $actions;
}
add_filter( 'um_admin_user_actions_hook', 'um_admin_user_actions_hook', 1 );
/**
@@ -62,7 +64,6 @@ function um_admin_user_actions_hook( $actions ) {
* @return string
* @hook_filter: um_clean_user_basename_filter
*/
add_filter('um_clean_user_basename_filter','um_clean_user_basename_filter',2,10);
function um_clean_user_basename_filter( $value, $raw ){
$permalink_base = UM()->options()->get( 'permalink_base' );
@@ -273,6 +274,7 @@ function um_clean_user_basename_filter( $value, $raw ){
return $value;
}
add_filter( 'um_clean_user_basename_filter', 'um_clean_user_basename_filter', 2, 10 );
/**
+5
View File
@@ -3,8 +3,13 @@ if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
/**
* Class UM_Menu_Item_Custom_Fields_Editor
*/
class UM_Menu_Item_Custom_Fields_Editor {
/**
* @var array
*/
+31 -3
View File
@@ -4,8 +4,17 @@ namespace um\widgets;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Class UM_Search_Widget
* @package um\widgets
*/
class UM_Search_Widget extends \WP_Widget {
/**
* UM_Search_Widget constructor.
*/
function __construct() {
parent::__construct(
@@ -22,7 +31,13 @@ class UM_Search_Widget extends \WP_Widget {
}
// Creating widget front-end
/**
* Creating widget front-end
*
* @param array $args
* @param array $instance
*/
public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
@@ -39,7 +54,12 @@ class UM_Search_Widget extends \WP_Widget {
echo $args['after_widget'];
}
// Widget Backend
/**
* Widget Backend
*
* @param array $instance
*/
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
@@ -64,7 +84,15 @@ class UM_Search_Widget extends \WP_Widget {
<?php
}
// Updating widget replacing old instances with new
/**
* Updating widget replacing old instances with new
*
* @param array $new_instance
* @param array $old_instance
*
* @return array
*/
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';