saved_fields = get_option('um_fields'); } /*** *** @regular or multi-select/options ***/ function is_dropdown_field( $field ) { $fields = $this->all_user_fields; if ( isset($fields[$field]['options']) ) return true; return false; } /*** *** @get specific fields ***/ 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]; } } return $array; } /*** *** @get specific field ***/ 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]; } } return $array; } /*** *** @Checks for a unique field error ***/ function unique_field_err( $key ){ global $ultimatemember; if ( empty( $key ) ) return 'Please provide a meta key'; if ( isset( $this->core_fields[ $key ] ) ) return 'Your meta key is a reserved core field and cannot be used'; if ( isset( $this->predefined_fields[ $key ] ) ) return 'Your meta key is a predefined reserved key and cannot be used'; if ( isset( $this->saved_fields[ $key ] ) ) return 'Your meta key already exists in your fields list'; if ( !$ultimatemember->validation->safe_string( $key ) ) return 'Your meta key contains illegal characters. Please correct it.'; return 0; } /*** *** @check date range errors (start date) ***/ function date_range_start_err( $date ) { global $ultimatemember; if ( empty( $date ) ) return 'Please provide a date range beginning'; if ( !$ultimatemember->validation->validate_date( $date ) ) return 'Please enter a valid start date in the date range'; return 0; } /*** *** @check date range errors (end date) ***/ function date_range_end_err( $date, $start_date ) { global $ultimatemember; if ( empty( $date ) ) return 'Please provide a date range end'; if ( !$ultimatemember->validation->validate_date( $date ) ) return 'Please enter a valid end date in the date range'; if ( strtotime( $date ) <= strtotime( $start_date ) ) return 'The end of date range must be greater than the start of date range'; return 0; } /*** *** @Get a core field attrs ***/ function get_core_field_attrs( $type ) { return ( isset( $this->core_fields[$type] ) ) ? $this->core_fields[$type] : array(''); } /*** *** @Core Fields ***/ function set_core_fields(){ $this->core_fields = array( 'row' => array( 'name' => 'Row', 'in_fields' => false, 'form_only' => true, 'conditional_support' => 0, 'icon' => 'um-icon-pencil-2', 'col1' => array('_id','_background','_text_color','_padding','_margin','_border','_borderradius','_borderstyle','_bordercolor'), 'col2' => array('_heading','_heading_text','_heading_background_color','_heading_text_color','_icon','_icon_color','_css_class'), ), 'text' => array( 'name' => 'Text Box', 'col1' => array('_title','_metakey','_help','_default','_min_chars'), 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), ) ), 'textarea' => array( 'name' => 'Textarea', 'col1' => array('_title','_metakey','_help','_height','_max_chars','_max_words','_html'), 'col2' => array('_label','_placeholder','_public','_roles','_default'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), ) ), 'select' => array( 'name' => 'Dropdown', 'col1' => array('_title','_metakey','_help','_default','_options'), 'col2' => array('_label','_placeholder','_public','_roles'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), '_options' => array( 'mode' => 'required', 'error' => 'You have not added any choices yet.' ), ) ), 'multiselect' => array( 'name' => 'Multi-Select', 'col1' => array('_title','_metakey','_help','_default','_options'), 'col2' => array('_label','_placeholder','_public','_roles','_min_selections','_max_selections'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), '_options' => array( 'mode' => 'required', 'error' => 'You have not added any choices yet.' ), ) ), 'radio' => array( 'name' => 'Radio', 'col1' => array('_title','_metakey','_help','_default','_options'), 'col2' => array('_label','_public','_roles'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), '_options' => array( 'mode' => 'required', 'error' => 'You have not added any choices yet.' ), ) ), 'checkbox' => array( 'name' => 'Checkbox', 'col1' => array('_title','_metakey','_help','_default','_options'), 'col2' => array('_label','_public','_roles','_max_selections'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), '_options' => array( 'mode' => 'required', 'error' => 'You have not added any choices yet.' ), ) ), 'url' => array( 'name' => 'URL', 'col1' => array('_title','_metakey','_help','_default','_url_text'), 'col2' => array('_label','_placeholder','_url_target','_url_rel','_public','_roles','_validate','_custom_validate'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), ) ), 'password' => array( 'name' => 'Password', 'col1' => array('_title','_metakey','_help','_min_chars','_max_chars'), 'col2' => array('_label','_placeholder','_public','_roles','_force_good_pass','_force_confirm_pass'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), ) ), 'image' => array( 'name' => 'Image Upload', 'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_crop'), 'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), '_max_size' => array( 'mode' => 'numeric', 'error' => 'Please enter a valid size' ), ) ), 'file' => array( 'name' => 'File Upload', 'col1' => array('_title','_metakey','_help','_allowed_types','_max_size'), 'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), '_max_size' => array( 'mode' => 'numeric', 'error' => 'Please enter a valid size' ), ) ), 'date' => array( 'name' => 'Date Picker', 'col1' => array('_title','_metakey','_help','_range','_years','_years_x','_range_start','_range_end'), 'col2' => array('_label','_placeholder','_public','_roles','_format','_pretty_format','_disabled_weekdays'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), '_years' => array( 'mode' => 'numeric', 'error' => 'Number of years is not valid' ), '_range_start' => array( 'mode' => 'range-start', ), '_range_end' => array( 'mode' => 'range-end', ), ) ), 'time' => array( 'name' => 'Time Picker', 'col1' => array('_title','_metakey','_help','_format'), 'col2' => array('_label','_placeholder','_public','_roles','_intervals'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), ) ), 'rating' => array( 'name' => 'Rating', 'col1' => array('_title','_metakey','_help'), 'col2' => array('_label','_public','_roles','_number','_default'), 'col3' => array('_required','_editable','_icon'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_metakey' => array( 'mode' => 'unique', ), ) ), 'block' => array( 'name' => 'Content Block', 'col1' => array('_title'), 'col2' => array('_public','_roles'), 'col_full' => array('_content'), 'mce_content' => true, 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), 'um_editor' => array( 'mode' => 'required', 'error' => 'You must add some content first' ), ) ), 'shortcode' => array( 'name' => 'Shortcode', 'col1' => array('_title'), 'col2' => array('_public','_roles'), 'col_full' => array('_content'), 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_content' => array( 'mode' => 'required', 'error' => 'You must add a shortcode to the content area' ), ) ), 'spacing' => array( 'name' => 'Spacing', 'col1' => array('_title'), 'col2' => array('_spacing'), 'form_only' => true, 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), ) ), 'divider' => array( 'name' => 'Divider', 'col1' => array('_title','_width'), 'col2' => array('_style','_color'), 'form_only' => true, 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), ) ), 'group' => array( 'name' => 'Field Group', 'col1' => array('_title','_max_entries'), 'col2' => array('_label','_public','_roles'), 'form_only' => true, 'validate' => array( '_title' => array( 'mode' => 'required', 'error' => 'You must provide a title' ), '_label' => array( 'mode' => 'required', 'error' => 'You must provide a label' ), ) ), ); $this->core_fields = apply_filters('um_core_fields_hook', $this->core_fields ); } /*** *** @Predefined Fields ***/ function set_predefined_fields(){ global $ultimatemember; $this->predefined_fields = array( 'user_login' => array( 'title' => 'Username', 'metakey' => 'user_login', 'type' => 'text', 'label' => 'Username', 'required' => 1, 'public' => 1, 'editable' => 0, 'validate' => 'unique_username', 'min_chars' => 3, 'max_chars' => 24 ), 'username' => array( 'title' => 'Username or E-mail', 'metakey' => 'username', 'type' => 'text', 'label' => 'Username or E-mail', 'required' => 1, 'public' => 1, 'editable' => 0, 'validate' => 'unique_username_or_email', ), 'user_password' => array( 'title' => 'Password', 'metakey' => 'user_password', 'type' => 'password', 'label' => 'Password', 'required' => 1, 'public' => 1, 'editable' => 1, 'min_chars' => 8, 'max_chars' => 30, 'force_good_pass' => 1, 'force_confirm_pass' => 1, ), 'first_name' => array( 'title' => 'First Name', 'metakey' => 'first_name', 'type' => 'text', 'label' => 'First Name', 'required' => 0, 'public' => 1, 'editable' => 1, ), 'last_name' => array( 'title' => 'Last Name', 'metakey' => 'last_name', 'type' => 'text', 'label' => 'Last Name', 'required' => 0, 'public' => 1, 'editable' => 1, ), 'display_name' => array( 'title' => 'Display Name', 'metakey' => 'display_name', 'type' => 'text', 'label' => 'Display Name', 'required' => 0, 'public' => 1, 'editable' => 1, ), 'user_email' => array( 'title' => 'E-mail Address', 'metakey' => 'user_email', 'type' => 'text', 'label' => 'E-mail Address', 'required' => 0, 'public' => 1, 'editable' => 1, 'validate' => 'unique_email', ), 'description' => array( 'title' => 'Biography', 'metakey' => 'description', 'type' => 'textarea', 'label' => 'Biography', 'html' => 0, 'required' => 0, 'public' => 1, 'editable' => 1, 'max_words' => 40, 'placeholder' => 'Enter a bit about yourself...', ), 'birth_date' => array( 'title' => 'Birth Date', 'metakey' => 'birth_date', 'type' => 'date', 'label' => 'Birth Date', 'required' => 0, 'public' => 1, 'editable' => 1, 'pretty_format' => 1, 'years' => 115, 'years_x' => 'past', 'icon' => 'um-icon-calendar-2' ), 'gender' => array( 'title' => 'Gender', 'metakey' => 'gender', 'type' => 'radio', 'label' => 'Gender', 'required' => 0, 'public' => 1, 'editable' => 1, 'options' => array('Male','Female') ), 'country' => array( 'title' => 'Countries', 'metakey' => 'country', 'type' => 'select', 'label' => 'Country', 'placeholder' => 'Choose a Country', 'required' => 0, 'public' => 1, 'editable' => 1, 'options' => $this->get('countries') ), 'facebook' => array( 'title' => 'Facebook', 'metakey' => 'facebook', 'type' => 'url', 'label' => 'Facebook', 'required' => 0, 'public' => 1, 'editable' => 1, 'url_target' => '_blank', 'url_rel' => 'nofollow', 'icon' => 'um-icon-facebook-alt', 'validate' => 'facebook_url', 'url_text' => 'Facebook', ), 'twitter' => array( 'title' => 'Twitter', 'metakey' => 'twitter', 'type' => 'url', 'label' => 'Twitter', 'required' => 0, 'public' => 1, 'editable' => 1, 'url_target' => '_blank', 'url_rel' => 'nofollow', 'icon' => 'um-icon-twitter', 'validate' => 'twitter_url', 'url_text' => 'Twitter', ), 'linkedin' => array( 'title' => 'LinkedIn', 'metakey' => 'linkedin', 'type' => 'url', 'label' => 'LinkedIn', 'required' => 0, 'public' => 1, 'editable' => 1, 'url_target' => '_blank', 'url_rel' => 'nofollow', 'icon' => 'um-icon-linkedin-alt-1', 'validate' => 'linkedin_url', 'url_text' => 'LinkedIn', ), 'googleplus' => array( 'title' => 'Google+', 'metakey' => 'googleplus', 'type' => 'url', 'label' => 'Google+', 'required' => 0, 'public' => 1, 'editable' => 1, 'url_target' => '_blank', 'url_rel' => 'nofollow', 'icon' => 'um-icon-google-plus', 'validate' => 'google_url', 'url_text' => 'Google+', ), 'instagram' => array( 'title' => 'Instagram', 'metakey' => 'instagram', 'type' => 'url', 'label' => 'Instagram', 'required' => 0, 'public' => 1, 'editable' => 1, 'url_target' => '_blank', 'url_rel' => 'nofollow', 'icon' => 'um-icon-instagrem', 'validate' => 'instagram_url', 'url_text' => 'Instagram', ), 'skype' => array( 'title' => 'Skype ID', 'metakey' => 'skype', 'type' => 'url', 'label' => 'Skype ID', 'required' => 0, 'public' => 1, 'editable' => 1, 'url_target' => '_blank', 'url_rel' => 'nofollow', 'icon' => 'um-icon-skype', 'validate' => 'skype', 'url_text' => 'Skype', ), 'role_select' => array( 'title' => 'Roles (Dropdown)', 'metakey' => 'role_select', 'type' => 'select', 'label' => 'Account Type', 'placeholder' => 'Choose account type', 'required' => 0, 'public' => 1, 'editable' => 1, 'options' => $ultimatemember->query->get_roles( false, array('admin') ), ), 'role_radio' => array( 'title' => 'Roles (Radio)', 'metakey' => 'role_radio', 'type' => 'radio', 'label' => 'Account Type', 'required' => 0, 'public' => 1, 'editable' => 1, 'options' => $ultimatemember->query->get_roles( false, array('admin') ), ), 'languages' => array( 'title' => 'Languages', 'metakey' => 'languages', 'type' => 'multiselect', 'label' => 'Languages Spoken', 'placeholder' => 'Select languages', 'required' => 0, 'public' => 1, 'editable' => 1, 'options' => $this->get('languages'), ), 'phone_number' => array( 'title' => 'Phone Number', 'metakey' => 'phone_number', 'type' => 'text', 'label' => 'Phone Number', 'required' => 0, 'public' => 1, 'editable' => 1, 'validate' => 'phone_number', 'icon' => 'um-icon-phone', ), 'mobile_number' => array( 'title' => 'Mobile Number', 'metakey' => 'mobile_number', 'type' => 'text', 'label' => 'Mobile Number', 'required' => 0, 'public' => 1, 'editable' => 1, 'validate' => 'phone_number', 'icon' => 'um-icon-device-mobile', ), // private use ( not public list ) 'profile_photo' => array( 'title' => 'Profile Photo', 'metakey' => 'profile_photo', 'type' => 'image', 'label' => 'Change your profile photo', 'upload_text' => 'Upload your photo here', 'icon' => 'um-icon-camera-5', 'crop' => 1, 'min_width' => str_replace('px','',um_get_option('profile_photosize')), 'min_height' => str_replace('px','',um_get_option('profile_photosize')), 'private_use' => true, ), 'cover_photo' => array( 'title' => 'Cover Photo', 'metakey' => 'cover_photo', 'type' => 'image', 'label' => 'Change your cover photo', 'upload_text' => 'Upload profile cover here', 'icon' => 'um-icon-photo-2', 'crop' => 2, 'modal_size' => 'large', 'ratio' => str_replace(':1','',um_get_option('profile_cover_ratio')), 'min_width' => um_get_option('cover_min_width'), 'private_use' => true, ), 'password_reset_text' => array( 'title' => 'Password Reset', 'type' => 'block', 'content' => '