Ultimate Member – User Profile & Membership Plugin - Version 2.1.17

Version Description

Download this release

Release Info

Developer nsinelnikov
Plugin Icon 128x128 Ultimate Member – User Profile & Membership Plugin
Version 2.1.17
Comparing to
See all releases

Code changes from version 2.1.16 to 2.1.17

assets/js/um-scripts.js CHANGED
@@ -124,14 +124,13 @@ jQuery(document).ready(function() {
124
  function unselectEmptyOption( e ) {
125
  var $element = jQuery( e.currentTarget );
126
  var $selected = $element.find(':selected');
127
- if ( $selected.length > 1 ) {
128
- $selected.each( function ( i, option ) {
129
- if ( option.value === '' ) {
130
- option.selected = false;
131
- $element.trigger( 'change' );
132
- }
133
- });
134
- }
135
  }
136
 
137
  if ( typeof( jQuery.fn.select2 ) === 'function' ) {
124
  function unselectEmptyOption( e ) {
125
  var $element = jQuery( e.currentTarget );
126
  var $selected = $element.find(':selected');
127
+
128
+ $selected.each( function ( i, option ) {
129
+ if ( option.value === '' ) {
130
+ option.selected = false;
131
+ $element.trigger( 'change' );
132
+ }
133
+ });
 
134
  }
135
 
136
  if ( typeof( jQuery.fn.select2 ) === 'function' ) {
assets/js/um-scripts.min.js CHANGED
@@ -1 +1 @@
1
- function um_init_datetimepicker(){jQuery(".um-datepicker:not(.picker__input)").each(function(){var e=jQuery(this),t=!1;void 0!==e.attr("data-disabled_weekdays")&&""!==e.attr("data-disabled_weekdays")&&(t=JSON.parse(e.attr("data-disabled_weekdays")));var a=null;void 0!==e.attr("data-years")&&(a=e.attr("data-years"));var i=e.attr("data-date_min"),r=e.attr("data-date_max"),n=[],u=[];void 0!==i&&(n=i.split(",")),void 0!==r&&(u=r.split(","));var o=n.length?new Date(n):null,d=n.length?new Date(u):null;if(o&&"Invalid Date"==o.toString()&&3==n.length){var s=n[1]+"/"+n[2]+"/"+n[0];o=new Date(Date.parse(s))}if(d&&"Invalid Date"==d.toString()&&3==u.length){var l=u[1]+"/"+u[2]+"/"+u[0];d=new Date(Date.parse(l))}var c={disable:t,format:e.attr("data-format"),formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}};null!==a&&(c.selectYears=a),null!==o&&(c.min=o),null!==d&&(c.max=d),e.pickadate(c)}),jQuery(".um-timepicker:not(.picker__input)").each(function(){var e=jQuery(this);e.pickatime({format:e.attr("data-format"),interval:parseInt(e.attr("data-intervals")),formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}})})}function init_tipsy(){"function"==typeof jQuery.fn.tipsy&&(jQuery(".um-tip-n").tipsy({gravity:"n",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-w").tipsy({gravity:"w",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-e").tipsy({gravity:"e",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-s").tipsy({gravity:"s",opacity:1,live:"a.live",offset:3}))}jQuery(document).ready(function(){function a(e){var a=jQuery(e.currentTarget),t=a.find(":selected");1<t.length&&t.each(function(e,t){""===t.value&&(t.selected=!1,a.trigger("change"))})}jQuery(document.body).on("click",".um-dropdown a.real_url",function(){window.location=jQuery(this).attr("href")}),jQuery(document.body).on("click",".um-trigger-menu-on-click",function(){var e=jQuery(this).find(".um-dropdown");return UM.dropdown.show(e),!1}),jQuery(document.body).on("click",".um-dropdown-hide",function(){return UM.dropdown.hideAll(),!1}),jQuery(document.body).on("click","a.um-manual-trigger",function(){var e=jQuery(this).attr("data-child"),t=jQuery(this).attr("data-parent");return jQuery(this).parents(t).find(e).trigger("click"),UM.dropdown.hideAll(),!1}),jQuery(".um-s1,.um-s2").css({display:"block"}),"function"==typeof jQuery.fn.select2&&(jQuery(".um-s1").each(function(e){var t=jQuery(this);t.select2({allowClear:!0,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s2").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:10,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s3").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:-1,dropdownParent:t.parent()}).on("change",a)})),init_tipsy(),"function"==typeof jQuery.fn.um_raty&&(jQuery(".um-rating").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,click:function(e,t){um_live_field=this.id,um_live_value=e,um_apply_conditions(jQuery(this),!1)}}),jQuery(".um-rating-readonly").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,readOnly:!0})),jQuery(document).on("change",'.um-field-area input[type="radio"]',function(){var e=jQuery(this).parents(".um-field-area"),t=jQuery(this).parents("label");e.find(".um-field-radio").removeClass("active"),e.find(".um-field-radio").find("i").removeAttr("class").addClass("um-icon-android-radio-button-off"),t.addClass("active"),t.find("i").removeAttr("class").addClass("um-icon-android-radio-button-on")}),jQuery(document).on("change",'.um-field-area input[type="checkbox"]',function(){var e=jQuery(this).parents("label");e.hasClass("active")?(e.removeClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline-blank")):(e.addClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline"))}),um_init_datetimepicker(),jQuery(document).on("click",".um .um-single-image-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-image-preview img").attr("src"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-image-preview img").attr("src",""),t.find(".um-single-image-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find("input[type=hidden]").val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um .um-single-file-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-fileinfo a").attr("href"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-file-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find("input[type=hidden]").val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um-field-group-head:not(.disabled)",function(){var e=jQuery(this).parents(".um-field-group"),t=e.data("max_entries");e.find(".um-field-group-body").is(":hidden")?e.find(".um-field-group-body").show():e.find(".um-field-group-body:first").clone().appendTo(e);var a=0;e.find(".um-field-group-body").each(function(){a++,jQuery(this).find("input").each(function(){var e=jQuery(this);e.attr("id",e.data("key")+"-"+a),e.attr("name",e.data("key")+"-"+a),e.parent().parent().find("label").attr("for",e.data("key")+"-"+a)})}),0<t&&e.find(".um-field-group-body").length==t&&jQuery(this).addClass("disabled")}),jQuery(document).on("click",".um-field-group-cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field-group"),a=t.data("max_entries");return 1<t.find(".um-field-group-body").length?jQuery(this).parents(".um-field-group-body").remove():jQuery(this).parents(".um-field-group-body").hide(),0<a&&t.find(".um-field-group-body").length<a&&t.find(".um-field-group-head").removeClass("disabled"),!1}),jQuery(document.body).on("click",".um-ajax-paginate",function(e){e.preventDefault();var t=jQuery(this),a=t.parent();a.addClass("loading");var i=1*t.data("pages"),r=1*t.data("page")+1,n=t.data("hook");if("um_load_posts"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_posts",author:jQuery(this).data("author"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r===i?a.remove():t.data("page",r)}});else if("um_load_comments"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_comments",user_id:jQuery(this).data("user_id"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r===i?a.remove():t.data("page",r)}});else{var u=jQuery(this).data("args"),o=jQuery(this).parents(".um").find(".um-ajax-items");jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate",hook:n,args:u,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.remove(),o.append(e)}})}}),jQuery(document).on("click",".um-ajax-action",function(e){e.preventDefault();var t=jQuery(this).data("hook"),a=jQuery(this).data("user_id"),arguments=jQuery(this).data("arguments");return jQuery(this).data("js-remove")&&jQuery(this).parents("."+jQuery(this).data("js-remove")).fadeOut("fast"),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_muted_action",hook:t,user_id:a,arguments:arguments,nonce:um_scripts.nonce},success:function(e){}}),!1}),jQuery(document.body).on("click","#um-search-button",function(){var e=jQuery(this).parents(".um-search-form").data("members_page"),t=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){t.push(jQuery(this).val())});var a,i=jQuery(this).parents(".um-search-form").find(".um-search-field").val();if(""===i)a=e;else{for(var r="?",n=0;n<t.length;n++)r+=t[n]+"="+i,n!==t.length-1&&(r+="&");a=e+r}window.location=a}),jQuery(document.body).on("keypress",".um-search-field",function(e){if(13===e.which){var t=jQuery(this).parents(".um-search-form").data("members_page"),a=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){a.push(jQuery(this).val())});var i,r=jQuery(this).val();if(""===r)i=t;else{for(var n="?",u=0;u<a.length;u++)n+=a[u]+"="+r,u!==a.length-1&&(n+="&");i=t+n}window.location=i}}),jQuery('.um-form input[class="um-button"][type="submit"]').prop("disabled",!1),jQuery(document).one("click",'.um:not(.um-account) .um-form input[class="um-button"][type="submit"]:not(.um-has-recaptcha)',function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parents("form").trigger("submit")});var o={};function d(t,e,a){var i=t.parents(".um-directory"),r=t.attr("name");t.find('option[value!=""]').remove(),t.hasClass("um-child-option-disabled")||t.prop("disabled",!1);var n=[];if("yes"===e.post.members_directory&&n.push({id:"",text:"",selected:1}),jQuery.each(e.items,function(e,t){n.push({id:e,text:t,selected:""===t})}),t.select2("destroy"),t.select2({data:n,allowClear:!0,minimumResultsForSearch:10}),"yes"===e.post.members_directory){t.find("option").each(function(){""!==jQuery(this).html()&&jQuery(this).data("value_label",jQuery(this).html()).attr("data-value_label",jQuery(this).html())});var u=um_get_data_for_directory(i,"filter_"+r);if(void 0!==u){u=u.split("||");var o=[];jQuery.each(u,function(e){t.find('option[value="'+u[e]+'"]').length&&o.push(u[e]),t.find('option[value="'+u[e]+'"]').prop("disabled",!0).hide(),1===t.find("option:not(:disabled)").length&&t.prop("disabled",!0),t.select2("destroy").select2(),t.val("").trigger("change")}),o=o.join("||"),u!==o&&(um_set_url_from_data(i,"filter_"+r,o),um_ajax_get_members(i))}um_change_tag(i)}"yes"!==e.post.members_directory&&(void 0===e.field.default||t.data("um-original-value")?""!==t.data("um-original-value")&&t.val(t.data("um-original-value")).trigger("change"):t.val(e.field.default).trigger("change"),0==e.field.editable&&(t.addClass("um-child-option-disabled"),t.attr("disabled","disabled")))}jQuery("select[data-um-parent]").each(function(){var r=jQuery(this),n=r.data("um-parent"),u=r.data("um-ajax-source");r.attr("data-um-init-field",!0),jQuery(document).on("change",'select[name="'+n+'"]',function(){var t,e=jQuery(this),a=e.closest("form").find('input[type="hidden"][name="form_id"]').val();if("yes"===r.attr("data-member-directory")){var i=e.parents(".um-directory");t=void 0!==(t=um_get_data_for_directory(i,"filter_"+n))?t.split("||"):""}else t=e.val();if(void 0!==t&&""!==t&&"object"!=typeof o[t]){if(void 0!==r.um_wait&&!1!==r.um_wait)return;r.um_wait=!0,jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_select_options",parent_option_name:n,parent_option:t,child_callback:u,child_name:r.attr("name"),members_directory:r.attr("data-member-directory"),form_id:a,nonce:um_scripts.nonce},success:function(e){"success"===e.status&&""!==t&&(o[t]=e,d(r,e,t)),void 0!==e.debug&&console.log(e),r.um_wait=!1},error:function(e){console.log(e),r.um_wait=!1}})}void 0!==t&&""!==t&&"object"==typeof o[t]&&setTimeout(d,10,r,o[t],t),void 0===t&&""!==t||(r.find('option[value!=""]').remove(),r.val("").trigger("change"))}),jQuery('select[name="'+n+'"]').trigger("change")})});
1
+ function um_init_datetimepicker(){jQuery(".um-datepicker:not(.picker__input)").each(function(){var e=jQuery(this),t=!1;void 0!==e.attr("data-disabled_weekdays")&&""!==e.attr("data-disabled_weekdays")&&(t=JSON.parse(e.attr("data-disabled_weekdays")));var a=null;void 0!==e.attr("data-years")&&(a=e.attr("data-years"));var i=e.attr("data-date_min"),r=e.attr("data-date_max"),n=[],u=[];void 0!==i&&(n=i.split(",")),void 0!==r&&(u=r.split(","));var o=n.length?new Date(n):null,d=n.length?new Date(u):null;if(o&&"Invalid Date"==o.toString()&&3==n.length){var s=n[1]+"/"+n[2]+"/"+n[0];o=new Date(Date.parse(s))}if(d&&"Invalid Date"==d.toString()&&3==u.length){var l=u[1]+"/"+u[2]+"/"+u[0];d=new Date(Date.parse(l))}var c={disable:t,format:e.attr("data-format"),formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}};null!==a&&(c.selectYears=a),null!==o&&(c.min=o),null!==d&&(c.max=d),e.pickadate(c)}),jQuery(".um-timepicker:not(.picker__input)").each(function(){var e=jQuery(this);e.pickatime({format:e.attr("data-format"),interval:parseInt(e.attr("data-intervals")),formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){e.blur()},onClose:function(){e.blur()}})})}function init_tipsy(){"function"==typeof jQuery.fn.tipsy&&(jQuery(".um-tip-n").tipsy({gravity:"n",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-w").tipsy({gravity:"w",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-e").tipsy({gravity:"e",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-s").tipsy({gravity:"s",opacity:1,live:"a.live",offset:3}))}jQuery(document).ready(function(){function a(e){var a=jQuery(e.currentTarget);a.find(":selected").each(function(e,t){""===t.value&&(t.selected=!1,a.trigger("change"))})}jQuery(document.body).on("click",".um-dropdown a.real_url",function(){window.location=jQuery(this).attr("href")}),jQuery(document.body).on("click",".um-trigger-menu-on-click",function(){var e=jQuery(this).find(".um-dropdown");return UM.dropdown.show(e),!1}),jQuery(document.body).on("click",".um-dropdown-hide",function(){return UM.dropdown.hideAll(),!1}),jQuery(document.body).on("click","a.um-manual-trigger",function(){var e=jQuery(this).attr("data-child"),t=jQuery(this).attr("data-parent");return jQuery(this).parents(t).find(e).trigger("click"),UM.dropdown.hideAll(),!1}),jQuery(".um-s1,.um-s2").css({display:"block"}),"function"==typeof jQuery.fn.select2&&(jQuery(".um-s1").each(function(e){var t=jQuery(this);t.select2({allowClear:!0,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s2").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:10,dropdownParent:t.parent()}).on("change",a)}),jQuery(".um-s3").each(function(e){var t=jQuery(this);t.select2({allowClear:!1,minimumResultsForSearch:-1,dropdownParent:t.parent()}).on("change",a)})),init_tipsy(),"function"==typeof jQuery.fn.um_raty&&(jQuery(".um-rating").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,click:function(e,t){um_live_field=this.id,um_live_value=e,um_apply_conditions(jQuery(this),!1)}}),jQuery(".um-rating-readonly").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,readOnly:!0})),jQuery(document).on("change",'.um-field-area input[type="radio"]',function(){var e=jQuery(this).parents(".um-field-area"),t=jQuery(this).parents("label");e.find(".um-field-radio").removeClass("active"),e.find(".um-field-radio").find("i").removeAttr("class").addClass("um-icon-android-radio-button-off"),t.addClass("active"),t.find("i").removeAttr("class").addClass("um-icon-android-radio-button-on")}),jQuery(document).on("change",'.um-field-area input[type="checkbox"]',function(){var e=jQuery(this).parents("label");e.hasClass("active")?(e.removeClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline-blank")):(e.addClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline"))}),um_init_datetimepicker(),jQuery(document).on("click",".um .um-single-image-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-image-preview img").attr("src"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-image-preview img").attr("src",""),t.find(".um-single-image-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find("input[type=hidden]").val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um .um-single-file-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=t.find('input[type="hidden"]#'+t.data("key")+"-"+jQuery(this).parents("form").find('input[type="hidden"][name="form_id"]').val()).val(),i=jQuery(this).parents(".um-field").find(".um-single-fileinfo a").attr("href"),r=t.data("mode"),n={data:{mode:r,filename:a,src:i,nonce:um_scripts.nonce},success:function(){t.find(".um-single-file-preview").hide(),t.find(".um-btn-auto-width").html(t.data("upload-label")),t.find("input[type=hidden]").val("empty_file")}};return"register"!==r&&(n.data.user_id=jQuery(this).parents("form").find("#user_id").val()),wp.ajax.send("um_remove_file",n),!1}),jQuery(document).on("click",".um-field-group-head:not(.disabled)",function(){var e=jQuery(this).parents(".um-field-group"),t=e.data("max_entries");e.find(".um-field-group-body").is(":hidden")?e.find(".um-field-group-body").show():e.find(".um-field-group-body:first").clone().appendTo(e);var a=0;e.find(".um-field-group-body").each(function(){a++,jQuery(this).find("input").each(function(){var e=jQuery(this);e.attr("id",e.data("key")+"-"+a),e.attr("name",e.data("key")+"-"+a),e.parent().parent().find("label").attr("for",e.data("key")+"-"+a)})}),0<t&&e.find(".um-field-group-body").length==t&&jQuery(this).addClass("disabled")}),jQuery(document).on("click",".um-field-group-cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field-group"),a=t.data("max_entries");return 1<t.find(".um-field-group-body").length?jQuery(this).parents(".um-field-group-body").remove():jQuery(this).parents(".um-field-group-body").hide(),0<a&&t.find(".um-field-group-body").length<a&&t.find(".um-field-group-head").removeClass("disabled"),!1}),jQuery(document.body).on("click",".um-ajax-paginate",function(e){e.preventDefault();var t=jQuery(this),a=t.parent();a.addClass("loading");var i=1*t.data("pages"),r=1*t.data("page")+1,n=t.data("hook");if("um_load_posts"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_posts",author:jQuery(this).data("author"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r===i?a.remove():t.data("page",r)}});else if("um_load_comments"===n)jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate_comments",user_id:jQuery(this).data("user_id"),page:r,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.before(e),r===i?a.remove():t.data("page",r)}});else{var u=jQuery(this).data("args"),o=jQuery(this).parents(".um").find(".um-ajax-items");jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_ajax_paginate",hook:n,args:u,nonce:um_scripts.nonce},complete:function(){a.removeClass("loading")},success:function(e){a.remove(),o.append(e)}})}}),jQuery(document).on("click",".um-ajax-action",function(e){e.preventDefault();var t=jQuery(this).data("hook"),a=jQuery(this).data("user_id"),arguments=jQuery(this).data("arguments");return jQuery(this).data("js-remove")&&jQuery(this).parents("."+jQuery(this).data("js-remove")).fadeOut("fast"),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_muted_action",hook:t,user_id:a,arguments:arguments,nonce:um_scripts.nonce},success:function(e){}}),!1}),jQuery(document.body).on("click","#um-search-button",function(){var e=jQuery(this).parents(".um-search-form").data("members_page"),t=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){t.push(jQuery(this).val())});var a,i=jQuery(this).parents(".um-search-form").find(".um-search-field").val();if(""===i)a=e;else{for(var r="?",n=0;n<t.length;n++)r+=t[n]+"="+i,n!==t.length-1&&(r+="&");a=e+r}window.location=a}),jQuery(document.body).on("keypress",".um-search-field",function(e){if(13===e.which){var t=jQuery(this).parents(".um-search-form").data("members_page"),a=[];jQuery(this).parents(".um-search-form").find('input[name="um-search-keys[]"]').each(function(){a.push(jQuery(this).val())});var i,r=jQuery(this).val();if(""===r)i=t;else{for(var n="?",u=0;u<a.length;u++)n+=a[u]+"="+r,u!==a.length-1&&(n+="&");i=t+n}window.location=i}}),jQuery('.um-form input[class="um-button"][type="submit"]').prop("disabled",!1),jQuery(document).one("click",'.um:not(.um-account) .um-form input[class="um-button"][type="submit"]:not(.um-has-recaptcha)',function(){jQuery(this).attr("disabled","disabled"),jQuery(this).parents("form").trigger("submit")});var o={};function d(t,e,a){var i=t.parents(".um-directory"),r=t.attr("name");t.find('option[value!=""]').remove(),t.hasClass("um-child-option-disabled")||t.prop("disabled",!1);var n=[];if("yes"===e.post.members_directory&&n.push({id:"",text:"",selected:1}),jQuery.each(e.items,function(e,t){n.push({id:e,text:t,selected:""===t})}),t.select2("destroy"),t.select2({data:n,allowClear:!0,minimumResultsForSearch:10}),"yes"===e.post.members_directory){t.find("option").each(function(){""!==jQuery(this).html()&&jQuery(this).data("value_label",jQuery(this).html()).attr("data-value_label",jQuery(this).html())});var u=um_get_data_for_directory(i,"filter_"+r);if(void 0!==u){u=u.split("||");var o=[];jQuery.each(u,function(e){t.find('option[value="'+u[e]+'"]').length&&o.push(u[e]),t.find('option[value="'+u[e]+'"]').prop("disabled",!0).hide(),1===t.find("option:not(:disabled)").length&&t.prop("disabled",!0),t.select2("destroy").select2(),t.val("").trigger("change")}),o=o.join("||"),u!==o&&(um_set_url_from_data(i,"filter_"+r,o),um_ajax_get_members(i))}um_change_tag(i)}"yes"!==e.post.members_directory&&(void 0===e.field.default||t.data("um-original-value")?""!==t.data("um-original-value")&&t.val(t.data("um-original-value")).trigger("change"):t.val(e.field.default).trigger("change"),0==e.field.editable&&(t.addClass("um-child-option-disabled"),t.attr("disabled","disabled")))}jQuery("select[data-um-parent]").each(function(){var r=jQuery(this),n=r.data("um-parent"),u=r.data("um-ajax-source");r.attr("data-um-init-field",!0),jQuery(document).on("change",'select[name="'+n+'"]',function(){var t,e=jQuery(this),a=e.closest("form").find('input[type="hidden"][name="form_id"]').val();if("yes"===r.attr("data-member-directory")){var i=e.parents(".um-directory");t=void 0!==(t=um_get_data_for_directory(i,"filter_"+n))?t.split("||"):""}else t=e.val();if(void 0!==t&&""!==t&&"object"!=typeof o[t]){if(void 0!==r.um_wait&&!1!==r.um_wait)return;r.um_wait=!0,jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_select_options",parent_option_name:n,parent_option:t,child_callback:u,child_name:r.attr("name"),members_directory:r.attr("data-member-directory"),form_id:a,nonce:um_scripts.nonce},success:function(e){"success"===e.status&&""!==t&&(o[t]=e,d(r,e,t)),void 0!==e.debug&&console.log(e),r.um_wait=!1},error:function(e){console.log(e),r.um_wait=!1}})}void 0!==t&&""!==t&&"object"==typeof o[t]&&setTimeout(d,10,r,o[t],t),void 0===t&&""!==t||(r.find('option[value!=""]').remove(),r.val("").trigger("change"))}),jQuery('select[name="'+n+'"]').trigger("change")})});
includes/admin/assets/css/um-admin-global.css CHANGED
@@ -203,8 +203,18 @@ a.um-delete{ color: #a00; }
203
  margin-bottom: 2px !important;
204
  }
205
 
 
 
 
 
206
  .um_hidden_notice,
207
- .um_block_settings_hide {
 
 
 
 
 
 
208
  display: none;
209
  }
210
 
203
  margin-bottom: 2px !important;
204
  }
205
 
206
+ /*
207
+ - Restrict access
208
+ */
209
+
210
  .um_hidden_notice,
211
+ .um_block_settings .um_block_settings_hide{
212
+ display: none;
213
+ }
214
+ .um_block_settings .components-select-control .components-select-control__input[multiple]{
215
+ height: auto;
216
+ }
217
+ .um_block_settings .components-select-control .components-select-control__input[multiple] + .components-input-control__suffix{
218
  display: none;
219
  }
220
 
includes/admin/assets/js/um-admin-blocks-shortcode.js CHANGED
@@ -365,7 +365,7 @@ wp.blocks.registerBlockType( 'um-block/um-account', {
365
  wp.i18n.__( 'Account', 'ultimate-member' )
366
  ),
367
  wp.element.createElement(
368
- wp.editor.InspectorControls,
369
  {},
370
  wp.element.createElement(
371
  wp.components.PanelBody,
365
  wp.i18n.__( 'Account', 'ultimate-member' )
366
  ),
367
  wp.element.createElement(
368
+ wp.blockEditor.InspectorControls,
369
  {},
370
  wp.element.createElement(
371
  wp.components.PanelBody,
includes/admin/assets/js/um-admin-blocks.js CHANGED
@@ -60,12 +60,13 @@ var um_block_restriction = wp.compose.createHigherOrderComponent( function( Bloc
60
  {},
61
  wp.element.createElement( BlockEdit, props ),
62
  wp.element.createElement(
63
- wp.editor.InspectorControls,
64
  {},
65
  wp.element.createElement(
66
  wp.components.PanelBody,
67
  {
68
- title: wp.i18n.__( 'UM access Controls', 'ultimate-member' )
 
69
  },
70
  wp.element.createElement(
71
  wp.components.ToggleControl,
60
  {},
61
  wp.element.createElement( BlockEdit, props ),
62
  wp.element.createElement(
63
+ wp.blockEditor.InspectorControls,
64
  {},
65
  wp.element.createElement(
66
  wp.components.PanelBody,
67
  {
68
+ title: wp.i18n.__( 'UM access Controls', 'ultimate-member' ),
69
+ className: 'um_block_settings'
70
  },
71
  wp.element.createElement(
72
  wp.components.ToggleControl,
includes/admin/assets/js/um-admin-field.js CHANGED
@@ -4,11 +4,11 @@ jQuery(document).ready(function() {
4
  jQuery(document.body).on('click', '.um-admin-btns a span.remove', function(e){
5
  e.preventDefault();
6
 
7
- if ( confirm( 'This will permanently delete this custom field from database' ) ) {
8
 
9
  jQuery(this).parents('a').remove();
10
 
11
- arg1 = jQuery(this).parents('a').data('arg1');
12
 
13
  jQuery.ajax({
14
  url: wp.ajax.settings.url,
@@ -20,10 +20,10 @@ jQuery(document).ready(function() {
20
  nonce: um_admin_scripts.nonce
21
 
22
  },
23
- success: function(data){
24
-
25
  },
26
- error: function(data){
27
 
28
  }
29
  });
4
  jQuery(document.body).on('click', '.um-admin-btns a span.remove', function(e){
5
  e.preventDefault();
6
 
7
+ if ( confirm( wp.i18n.__( 'This will permanently delete this custom field from a database and from all forms on your site. Are you sure?', 'ultimate-member' ) ) ) {
8
 
9
  jQuery(this).parents('a').remove();
10
 
11
+ var arg1 = jQuery(this).parents('a').data('arg1');
12
 
13
  jQuery.ajax({
14
  url: wp.ajax.settings.url,
20
  nonce: um_admin_scripts.nonce
21
 
22
  },
23
+ success: function(data) {
24
+ jQuery('#um-admin-form-builder .' + arg1).remove();
25
  },
26
+ error: function(data) {
27
 
28
  }
29
  });
includes/admin/assets/js/um-admin-forms.js CHANGED
@@ -774,10 +774,20 @@ jQuery(document).ready( function() {
774
  if ( input_type === 'checkbox' ) {
775
  own_condition = ( value == '1' ) ? cond_field.is(':checked') : ! cond_field.is(':checked');
776
  } else {
777
- own_condition = ( cond_field.val() == value );
 
 
 
 
778
  }
779
  } else if ( tagName === 'select' ) {
780
- own_condition = ( cond_field.val() == value );
 
 
 
 
 
 
781
  }
782
 
783
  if ( own_condition && parent_condition ) {
@@ -794,10 +804,22 @@ jQuery(document).ready( function() {
794
  if ( input_type == 'checkbox' ) {
795
  own_condition = ( value == '1' ) ? condition_field.is(':checked') : ! condition_field.is(':checked');
796
  } else {
797
- own_condition = ( condition_field.val() == value );
 
 
 
 
 
 
798
  }
799
  } else if ( tagName == 'select' ) {
800
- own_condition = ( condition_field.val() == value );
 
 
 
 
 
 
801
  }
802
 
803
  return ( own_condition && parent_condition );
774
  if ( input_type === 'checkbox' ) {
775
  own_condition = ( value == '1' ) ? cond_field.is(':checked') : ! cond_field.is(':checked');
776
  } else {
777
+ if ( Array.isArray( value ) ) {
778
+ own_condition = ( value.indexOf( cond_field.val() ) !== -1 );
779
+ } else {
780
+ own_condition = ( cond_field.val() == value );
781
+ }
782
  }
783
  } else if ( tagName === 'select' ) {
784
+
785
+ if ( Array.isArray( value ) ) {
786
+ own_condition = ( value.indexOf( cond_field.val() ) !== -1 );
787
+ } else {
788
+ own_condition = ( cond_field.val() == value );
789
+ }
790
+
791
  }
792
 
793
  if ( own_condition && parent_condition ) {
804
  if ( input_type == 'checkbox' ) {
805
  own_condition = ( value == '1' ) ? condition_field.is(':checked') : ! condition_field.is(':checked');
806
  } else {
807
+
808
+ if ( Array.isArray( value ) ) {
809
+ own_condition = ( value.indexOf( condition_field.val() ) !== -1 );
810
+ } else {
811
+ own_condition = ( condition_field.val() == value );
812
+ }
813
+
814
  }
815
  } else if ( tagName == 'select' ) {
816
+
817
+ if ( Array.isArray( value ) ) {
818
+ own_condition = ( value.indexOf( condition_field.val() ) !== -1 );
819
+ } else {
820
+ own_condition = ( condition_field.val() == value );
821
+ }
822
+
823
  }
824
 
825
  return ( own_condition && parent_condition );
includes/admin/core/class-admin-enqueue.php CHANGED
@@ -279,7 +279,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
279
  * Field Processing
280
  */
281
  function load_field() {
282
- wp_register_script( 'um_admin_field', $this->js_url . 'um-admin-field.js', array('jquery', 'wp-util'), ultimatemember_version, true );
283
  wp_enqueue_script( 'um_admin_field' );
284
  }
285
 
279
  * Field Processing
280
  */
281
  function load_field() {
282
+ wp_register_script( 'um_admin_field', $this->js_url . 'um-admin-field.js', array('jquery', 'wp-util', 'wp-i18n'), ultimatemember_version, true );
283
  wp_enqueue_script( 'um_admin_field' );
284
  }
285
 
includes/admin/core/class-admin-metabox.php CHANGED
@@ -2280,7 +2280,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
2280
  $privacy_options = array(
2281
  '1' => __( 'Everyone', 'ultimate-member' ),
2282
  '2' => __( 'Members', 'ultimate-member' ),
2283
- '-1' => __( 'Only visible to profile owner and admins', 'ultimate-member' ),
2284
  '-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ),
2285
  '-2' => __( 'Only specific member roles', 'ultimate-member' ),
2286
  );
2280
  $privacy_options = array(
2281
  '1' => __( 'Everyone', 'ultimate-member' ),
2282
  '2' => __( 'Members', 'ultimate-member' ),
2283
+ '-1' => __( 'Only visible to profile owner and users who can edit other member accounts', 'ultimate-member' ),
2284
  '-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ),
2285
  '-2' => __( 'Only specific member roles', 'ultimate-member' ),
2286
  );
includes/admin/core/class-admin-settings.php CHANGED
@@ -99,15 +99,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
99
 
100
  $metakeys = array();
101
  foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
102
- if ( $all_user_field['type'] == 'user_location' ) {
103
- $metakeys[] = $all_user_field['metakey'] . '_lat';
104
- $metakeys[] = $all_user_field['metakey'] . '_lng';
105
- $metakeys[] = $all_user_field['metakey'] . '_url';
106
- } else {
107
- $metakeys[] = $all_user_field['metakey'];
108
- }
109
  }
110
 
 
 
111
  if ( is_multisite() ) {
112
 
113
  $sites = get_sites( array( 'fields' => 'ids' ) );
@@ -336,7 +332,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
336
  'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
337
  'options' => UM()->roles()->get_roles(),
338
  'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
339
- 'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', 4 ),
340
  'size' => 'small'
341
  )
342
  );
@@ -651,7 +647,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
651
  '0' => __( 'No', 'ultimate-member' ),
652
  '1' => __( 'Yes', 'ultimate-member' ),
653
  ]
654
- )
 
 
 
 
 
 
 
655
  )
656
  ),
657
  'account' => array(
99
 
100
  $metakeys = array();
101
  foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
102
+ $metakeys[] = $all_user_field['metakey'];
 
 
 
 
 
 
103
  }
104
 
105
+ $metakeys = apply_filters( 'um_metadata_same_page_update_ajax', $metakeys, UM()->builtin()->all_user_fields );
106
+
107
  if ( is_multisite() ) {
108
 
109
  $sites = get_sites( array( 'fields' => 'ids' ) );
332
  'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
333
  'options' => UM()->roles()->get_roles(),
334
  'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
335
+ 'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', [ '4', '5' ] ),
336
  'size' => 'small'
337
  )
338
  );
647
  '0' => __( 'No', 'ultimate-member' ),
648
  '1' => __( 'Yes', 'ultimate-member' ),
649
  ]
650
+ ),
651
+ array(
652
+ 'id' => 'activation_link_expiry_time',
653
+ 'type' => 'number',
654
+ 'label' => __( 'Activation link lifetime', 'ultimate-member' ),
655
+ 'tooltip' => __( 'How long does an activation link live? Leave empty for endless links.', 'ultimate-member' ),
656
+ 'size' => 'small',
657
+ ),
658
  )
659
  ),
660
  'account' => array(
includes/admin/core/packages/2.1.17-alpha/functions.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ( ! defined( 'ABSPATH' ) ) exit;
2
+
3
+
4
+ /**
5
+ * @param $tab
6
+ *
7
+ * @return mixed
8
+ */
9
+ function um_upgrade_get_slug2117( $tab ) {
10
+ $slug = get_post_meta( $tab->ID, 'um_tab_slug', true );
11
+ if ( UM()->external_integrations()->is_wpml_active() ) {
12
+ global $sitepress;
13
+
14
+ $tab_id = $sitepress->get_object_id( $tab->ID, 'um_profile_tabs', true, $sitepress->get_default_language() );
15
+ if ( $tab_id && $tab_id != $tab->ID ) {
16
+ $slug = get_post_meta( $tab_id, 'um_tab_slug', true );
17
+ }
18
+ }
19
+
20
+ return $slug;
21
+ }
22
+
23
+
24
+ function um_upgrade_profile_tabs2117() {
25
+ UM()->admin()->check_ajax_nonce();
26
+
27
+ um_maybe_unset_time_limit();
28
+
29
+ $labels = [
30
+ 'name' => _x( 'Profile Tabs', 'Post Type General Name', 'ultimate-member' ),
31
+ 'singular_name' => _x( 'Profile tab', 'Post Type Singular Name', 'ultimate-member' ),
32
+ 'menu_name' => __( 'Profile Tabs', 'ultimate-member' ),
33
+ 'name_admin_bar' => __( 'Profile Tabs', 'ultimate-member' ),
34
+ 'archives' => __( 'Item Archives', 'ultimate-member' ),
35
+ 'attributes' => __( 'Item Attributes', 'ultimate-member' ),
36
+ 'parent_item_colon' => __( 'Parent Item:', 'ultimate-member' ),
37
+ 'all_items' => __( 'All Items', 'ultimate-member' ),
38
+ 'add_new_item' => __( 'Add New Item', 'ultimate-member' ),
39
+ 'add_new' => __( 'Add New', 'ultimate-member' ),
40
+ 'new_item' => __( 'New Item', 'ultimate-member' ),
41
+ 'edit_item' => __( 'Edit Item', 'ultimate-member' ),
42
+ 'update_item' => __( 'Update Item', 'ultimate-member' ),
43
+ 'view_item' => __( 'View Item', 'ultimate-member' ),
44
+ 'view_items' => __( 'View Items', 'ultimate-member' ),
45
+ 'search_items' => __( 'Search Item', 'ultimate-member' ),
46
+ 'not_found' => __( 'Not found', 'ultimate-member' ),
47
+ ];
48
+
49
+ $args = [
50
+ 'label' => __( 'Profile Tabs', 'ultimate-member' ),
51
+ 'description' => __( '', 'ultimate-member' ),
52
+ 'labels' => $labels,
53
+ 'supports' => ['title', 'editor' ],
54
+ 'hierarchical' => false,
55
+ 'public' => false,
56
+ 'show_ui' => true,
57
+ 'show_in_menu' => false,
58
+ 'menu_position' => 5,
59
+ 'show_in_admin_bar' => false,
60
+ 'show_in_nav_menus' => false,
61
+ 'can_export' => true,
62
+ 'has_archive' => false,
63
+ 'exclude_from_search' => true,
64
+ 'publicly_queryable' => true,
65
+ 'capability_type' => 'page',
66
+ ];
67
+
68
+ register_post_type( 'um_profile_tabs', $args );
69
+
70
+ $profile_tabs = get_posts( [
71
+ 'post_type' => 'um_profile_tabs',
72
+ 'orderby' => 'menu_order',
73
+ 'posts_per_page' => -1,
74
+ ] );
75
+
76
+ if ( ! empty( $profile_tabs ) ) {
77
+ $tabs_slugs = [];
78
+
79
+ foreach ( $profile_tabs as $tab ) {
80
+ $slug = um_upgrade_get_slug2117( $tab );
81
+ if ( ! empty( $slug ) && in_array( $slug, $tabs_slugs ) ) {
82
+ continue;
83
+ }
84
+
85
+ if ( preg_match( "/[a-z0-9]+$/i", urldecode( $tab->post_name ) ) ) {
86
+ $tab_slug = sanitize_title( $tab->post_name );
87
+ } else {
88
+ // otherwise use autoincrement and slug generator
89
+ $auto_increment = UM()->options()->get( 'custom_profiletab_increment' );
90
+ $auto_increment = ! empty( $auto_increment ) ? $auto_increment : 1;
91
+ $tab_slug = "custom_profiletab_{$auto_increment}";
92
+ }
93
+
94
+ if ( UM()->external_integrations()->is_wpml_active() ) {
95
+ global $sitepress;
96
+
97
+ $tab_id = $sitepress->get_object_id( $tab->ID, 'um_profile_tabs', true, $sitepress->get_default_language() );
98
+ if ( $tab_id && $tab_id == $tab->ID ) {
99
+ update_post_meta( $tab->ID, 'um_tab_slug', $tab_slug );
100
+
101
+ $tabs_slugs[] = $tab_slug;
102
+
103
+ if ( isset( $auto_increment ) ) {
104
+ $auto_increment++;
105
+ UM()->options()->update( 'custom_profiletab_increment', $auto_increment );
106
+ }
107
+
108
+ // show new profile tab by default - update UM Appearances > Profile Tabs settings
109
+ if ( UM()->options()->get( 'profile_tab_' . $tab_slug ) === '' ) {
110
+ UM()->options()->update( 'profile_tab_' . $tab_slug, '1' );
111
+ UM()->options()->update( 'profile_tab_' . $tab_slug . '_privacy', '0' );
112
+ }
113
+ }
114
+ } else {
115
+ update_post_meta( $tab->ID, 'um_tab_slug', $tab_slug );
116
+
117
+ $tabs_slugs[] = $tab_slug;
118
+
119
+ if ( isset( $auto_increment ) ) {
120
+ $auto_increment++;
121
+ UM()->options()->update( 'custom_profiletab_increment', $auto_increment );
122
+ }
123
+
124
+ // show new profile tab by default - update UM Appearances > Profile Tabs settings
125
+ if ( UM()->options()->get( 'profile_tab_' . $tab_slug ) === '' ) {
126
+ UM()->options()->update( 'profile_tab_' . $tab_slug, '1' );
127
+ UM()->options()->update( 'profile_tab_' . $tab_slug . '_privacy', '0' );
128
+ }
129
+ }
130
+ }
131
+ }
132
+
133
+ update_option( 'um_last_version_upgrade', '2.1.17-alpha' );
134
+
135
+ if ( ! empty( $profile_tabs ) ) {
136
+ wp_send_json_success( array( 'message' => __( 'Profile tabs have been updated successfully', 'ultimate-member' ) ) );
137
+ } else {
138
+ wp_send_json_success( array( 'message' => __( 'Database has been updated successfully', 'ultimate-member' ) ) );
139
+ }
140
+ }
includes/admin/core/packages/2.1.17-alpha/hooks.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php if ( ! defined( 'ABSPATH' ) ) exit;
2
+
3
+ return array(
4
+ 'profile_tabs2117' => 'profile_tabs2117',
5
+ );
includes/admin/core/packages/2.1.17-alpha/init.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
+
3
+
4
+ <script type="text/javascript">
5
+ jQuery( document ).ready( function() {
6
+ um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade profile tabs...', 'ultimate-member' ) ) ?>' );
7
+
8
+ jQuery.ajax({
9
+ url: wp.ajax.settings.url,
10
+ type: 'POST',
11
+ dataType: 'json',
12
+ data: {
13
+ action: 'um_profile_tabs2117',
14
+ nonce: um_admin_scripts.nonce
15
+ },
16
+ success: function( response ) {
17
+ if ( typeof response.data.message != 'undefined' ) {
18
+ um_add_upgrade_log( response.data.message );
19
+ //switch to the next package
20
+ um_run_upgrade();
21
+ } else {
22
+ um_wrong_ajax();
23
+ }
24
+ },
25
+ error: function() {
26
+ um_something_wrong();
27
+ }
28
+ });
29
+ });
30
+ </script>
includes/class-config.php CHANGED
@@ -577,6 +577,7 @@ if ( ! class_exists( 'um\Config' ) ) {
577
  'member_directory_own_table' => 0,
578
  'profile_show_html_bio' => 0,
579
  'profile_noindex' => 0,
 
580
  );
581
 
582
  add_filter( 'um_get_tabs_from_config', '__return_true' );
577
  'member_directory_own_table' => 0,
578
  'profile_show_html_bio' => 0,
579
  'profile_noindex' => 0,
580
+ 'activation_link_expiry_time' => '',
581
  );
582
 
583
  add_filter( 'um_get_tabs_from_config', '__return_true' );
includes/core/class-access.php CHANGED
@@ -59,6 +59,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
59
  add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 );
60
  //filter menu items
61
  add_filter( 'wp_nav_menu_objects', array( &$this, 'filter_menu' ), 99, 2 );
 
 
 
 
62
 
63
  //filter attachment
64
  add_filter( 'wp_get_attachment_url', array( &$this, 'filter_attachment' ), 99, 2 );
@@ -756,7 +760,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
756
  }
757
 
758
  $this->current_single_post = $post;
759
- add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
760
 
761
  /**
762
  * UM hook
@@ -858,7 +861,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
858
  $post->post_content = stripslashes( $restricted_global_message );
859
 
860
  $this->current_single_post = $post;
861
- add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
862
 
863
  if ( 'attachment' == $post->post_type ) {
864
  remove_filter( 'the_content', 'prepend_attachment' );
@@ -867,7 +869,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
867
  $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
868
 
869
  $this->current_single_post = $post;
870
- add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
871
 
872
  if ( 'attachment' == $post->post_type ) {
873
  remove_filter( 'the_content', 'prepend_attachment' );
@@ -947,7 +948,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
947
  $post->post_content = stripslashes( $restricted_global_message );
948
 
949
  $this->current_single_post = $post;
950
- add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
951
 
952
  if ( 'attachment' == $post->post_type ) {
953
  remove_filter( 'the_content', 'prepend_attachment' );
@@ -956,7 +956,6 @@ if ( ! class_exists( 'um\core\Access' ) ) {
956
  $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
957
 
958
  $this->current_single_post = $post;
959
- add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 );
960
 
961
  if ( 'attachment' == $post->post_type ) {
962
  remove_filter( 'the_content', 'prepend_attachment' );
@@ -1033,16 +1032,41 @@ if ( ! class_exists( 'um\core\Access' ) ) {
1033
 
1034
 
1035
  /**
1036
- * @param $content
1037
  *
 
1038
  * @return string
1039
  */
1040
  function replace_post_content( $content ) {
1041
- $content = $this->current_single_post->post_content;
 
 
1042
  return $content;
1043
  }
1044
 
1045
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1046
  /**
1047
  * Disable comments if user has not permission to access this post
1048
  *
59
  add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 );
60
  //filter menu items
61
  add_filter( 'wp_nav_menu_objects', array( &$this, 'filter_menu' ), 99, 2 );
62
+
63
+ // turn on/off content replacement on the filter 'the_content'
64
+ add_action( 'get_header', array( &$this, 'replace_post_content_on' ), 12 );
65
+ add_action( 'get_footer', array( &$this, 'replace_post_content_off' ), 8 );
66
 
67
  //filter attachment
68
  add_filter( 'wp_get_attachment_url', array( &$this, 'filter_attachment' ), 99, 2 );
760
  }
761
 
762
  $this->current_single_post = $post;
 
763
 
764
  /**
765
  * UM hook
861
  $post->post_content = stripslashes( $restricted_global_message );
862
 
863
  $this->current_single_post = $post;
 
864
 
865
  if ( 'attachment' == $post->post_type ) {
866
  remove_filter( 'the_content', 'prepend_attachment' );
869
  $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
870
 
871
  $this->current_single_post = $post;
 
872
 
873
  if ( 'attachment' == $post->post_type ) {
874
  remove_filter( 'the_content', 'prepend_attachment' );
948
  $post->post_content = stripslashes( $restricted_global_message );
949
 
950
  $this->current_single_post = $post;
 
951
 
952
  if ( 'attachment' == $post->post_type ) {
953
  remove_filter( 'the_content', 'prepend_attachment' );
956
  $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
957
 
958
  $this->current_single_post = $post;
 
959
 
960
  if ( 'attachment' == $post->post_type ) {
961
  remove_filter( 'the_content', 'prepend_attachment' );
1032
 
1033
 
1034
  /**
1035
+ * Replace the content on the filter 'the_content'
1036
  *
1037
+ * @param $content
1038
  * @return string
1039
  */
1040
  function replace_post_content( $content ) {
1041
+ if ( ! empty( $this->current_single_post ) ) {
1042
+ $content = $this->current_single_post->post_content;
1043
+ }
1044
  return $content;
1045
  }
1046
 
1047
 
1048
+ /**
1049
+ * Turn on the content replacement on the filter 'the_content'
1050
+ *
1051
+ * @hooked get_header 12
1052
+ * @since 2.1.17
1053
+ */
1054
+ public function replace_post_content_on() {
1055
+ add_filter( 'the_content', array( $this, 'replace_post_content' ), 9999, 1 );
1056
+ }
1057
+
1058
+
1059
+ /**
1060
+ * Turn off the content replacement on the filter 'the_content'
1061
+ *
1062
+ * @hooked get_footer 8
1063
+ * @since 2.1.17
1064
+ */
1065
+ public function replace_post_content_off() {
1066
+ remove_filter( 'the_content', array( $this, 'replace_post_content' ), 9999 );
1067
+ }
1068
+
1069
+
1070
  /**
1071
  * Disable comments if user has not permission to access this post
1072
  *
includes/core/class-fields.php CHANGED
@@ -256,6 +256,14 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
256
  do_action( 'um_delete_custom_field', $id, $args );
257
 
258
  update_option( 'um_fields', $fields );
 
 
 
 
 
 
 
 
259
  }
260
  }
261
 
@@ -1045,9 +1053,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
1045
  if ( ! $this->editing || 'custom' == $this->set_mode ) {
1046
  // show default on register screen if there is default
1047
  if ( isset( $data['default'] ) ) {
1048
- if ( ! is_array( $data['default'] ) && strstr( $data['default'], ', ' ) ) {
1049
- $data['default'] = explode( ', ', $data['default'] );
1050
- }
1051
 
1052
  if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
1053
  return true;
@@ -1061,6 +1066,14 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
1061
  return true;
1062
  }
1063
 
 
 
 
 
 
 
 
 
1064
  }
1065
  } else {
1066
 
@@ -2395,11 +2408,17 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
2395
  $name = $key;
2396
  }
2397
 
2398
- $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
 
 
 
 
 
2399
 
2400
- $output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
 
2401
 
2402
- </div>';
2403
 
2404
  if ( $this->is_error( $key ) ) {
2405
  $output .= $this->field_error( $this->show_error( $key ) );
256
  do_action( 'um_delete_custom_field', $id, $args );
257
 
258
  update_option( 'um_fields', $fields );
259
+
260
+ global $wpdb;
261
+ $forms = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_form'" );
262
+ foreach ( $forms as $form_id ) {
263
+ $form_fields = get_post_meta( $form_id, '_um_custom_fields', true );
264
+ unset( $form_fields[ $id ] );
265
+ update_post_meta( $form_id, '_um_custom_fields', $form_fields );
266
+ }
267
  }
268
  }
269
 
1053
  if ( ! $this->editing || 'custom' == $this->set_mode ) {
1054
  // show default on register screen if there is default
1055
  if ( isset( $data['default'] ) ) {
 
 
 
1056
 
1057
  if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
1058
  return true;
1066
  return true;
1067
  }
1068
 
1069
+ // default value with comma
1070
+ if ( is_string( $data['default'] ) && strstr( $data['default'], ',' ) ) {
1071
+ $choices = array_map( 'trim', explode( ',', $data['default'] ) );
1072
+ if ( in_array( $value, $choices ) ) {
1073
+ return true;
1074
+ }
1075
+ }
1076
+
1077
  }
1078
  } else {
1079
 
2408
  $name = $key;
2409
  }
2410
 
2411
+ if( ! empty( $placeholder ) && ! isset( $data['label'] ) ){
2412
+ $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
2413
+ }else if( isset( $data['label'] ) ){
2414
+ $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
2415
+ }
2416
+
2417
 
2418
+ $output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />';
2419
+
2420
 
2421
+ $output .= '</div>';
2422
 
2423
  if ( $this->is_error( $key ) ) {
2424
  $output .= $this->field_error( $this->show_error( $key ) );
includes/core/class-files.php CHANGED
@@ -39,7 +39,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
39
 
40
  $this->setup_paths();
41
 
42
- add_action( 'template_redirect', array( &$this, 'download_routing' ) );
43
 
44
  $this->fonticon = array(
45
  'pdf' => array('icon' => 'um-faicon-file-pdf-o', 'color' => '#D24D4D' ),
39
 
40
  $this->setup_paths();
41
 
42
+ add_action( 'template_redirect', array( &$this, 'download_routing' ), 1 );
43
 
44
  $this->fonticon = array(
45
  'pdf' => array('icon' => 'um-faicon-file-pdf-o', 'color' => '#D24D4D' ),
includes/core/class-form.php CHANGED
@@ -366,12 +366,15 @@ if ( ! class_exists( 'um\core\Form' ) ) {
366
  */
367
  $this->post_form = apply_filters( 'um_submit_post_form', $_POST );
368
 
 
 
 
 
369
  $this->post_form = $this->beautify( $this->post_form );
 
370
 
371
  $this->form_data = UM()->query()->post_data( $this->form_id );
372
 
373
- $this->post_form['submitted'] = $this->post_form;
374
-
375
  $this->post_form = array_merge( $this->form_data, $this->post_form );
376
 
377
  // Remove role from post_form at first if role ! empty and there aren't custom fields with role name
@@ -438,10 +441,6 @@ if ( ! class_exists( 'um\core\Form' ) ) {
438
 
439
  }
440
 
441
- if ( isset( $_POST[ UM()->honeypot ] ) && $_POST[ UM()->honeypot ] != '' ) {
442
- wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
443
- }
444
-
445
  /**
446
  * UM hook
447
  *
@@ -518,18 +517,19 @@ if ( ! class_exists( 'um\core\Form' ) ) {
518
 
519
  /**
520
  * Beautify form data
 
521
  * @param array $form
522
  * @return array $form
523
  */
524
- function beautify( $form ){
525
 
526
- if (isset($form['form_id'])){
527
 
528
  $this->form_suffix = '-' . $form['form_id'];
529
 
530
  $this->processing = $form['form_id'];
531
 
532
- foreach( $form as $key => $value ){
533
  if ( strstr( $key, $this->form_suffix ) ) {
534
  $a_key = str_replace( $this->form_suffix, '', $key );
535
  $form[ $a_key ] = $value;
366
  */
367
  $this->post_form = apply_filters( 'um_submit_post_form', $_POST );
368
 
369
+ if ( isset( $this->post_form[ UM()->honeypot ] ) && $this->post_form[ UM()->honeypot ] != '' ) {
370
+ wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
371
+ }
372
+
373
  $this->post_form = $this->beautify( $this->post_form );
374
+ $this->post_form['submitted'] = $this->post_form;
375
 
376
  $this->form_data = UM()->query()->post_data( $this->form_id );
377
 
 
 
378
  $this->post_form = array_merge( $this->form_data, $this->post_form );
379
 
380
  // Remove role from post_form at first if role ! empty and there aren't custom fields with role name
441
 
442
  }
443
 
 
 
 
 
444
  /**
445
  * UM hook
446
  *
517
 
518
  /**
519
  * Beautify form data
520
+ *
521
  * @param array $form
522
  * @return array $form
523
  */
524
+ function beautify( $form ) {
525
 
526
+ if ( isset( $form['form_id'] ) ) {
527
 
528
  $this->form_suffix = '-' . $form['form_id'];
529
 
530
  $this->processing = $form['form_id'];
531
 
532
+ foreach ( $form as $key => $value ) {
533
  if ( strstr( $key, $this->form_suffix ) ) {
534
  $a_key = str_replace( $this->form_suffix, '', $key );
535
  $form[ $a_key ] = $value;
includes/core/class-mail.php CHANGED
@@ -405,6 +405,8 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
405
  return;
406
  }
407
 
 
 
408
  $this->attachments = array();
409
  $this->headers = 'From: '. stripslashes( UM()->options()->get('mail_from') ) .' <'. UM()->options()->get('mail_from_addr') .'>' . "\r\n";
410
 
@@ -450,6 +452,8 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
450
 
451
  // Send mail
452
  wp_mail( $email, $this->subject, $this->message, $this->headers, $this->attachments );
 
 
453
  }
454
 
455
 
405
  return;
406
  }
407
 
408
+ do_action( 'um_before_email_notification_sending', $email, $template, $args );
409
+
410
  $this->attachments = array();
411
  $this->headers = 'From: '. stripslashes( UM()->options()->get('mail_from') ) .' <'. UM()->options()->get('mail_from_addr') .'>' . "\r\n";
412
 
452
 
453
  // Send mail
454
  wp_mail( $email, $this->subject, $this->message, $this->headers, $this->attachments );
455
+
456
+ do_action( 'um_after_email_notification_sending', $email, $template, $args );
457
  }
458
 
459
 
includes/core/class-member-directory-meta.php CHANGED
@@ -56,51 +56,25 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
56
  function on_delete_custom_field( $metakey, $args ) {
57
  $metakeys = get_option( 'um_usermeta_fields', array() );
58
 
59
- if ( $args['type'] == 'user_location' ) {
60
- if ( array_intersect( array( $metakey . '_lat', $metakey . '_lng', $metakey . '_url' ), $metakeys ) ) {
61
- if ( false !== $searched = array_search( $metakey . '_lat', $metakeys ) ) {
62
- unset( $metakeys[ $searched ] );
63
- }
64
- if ( false !== $searched = array_search( $metakey . '_lng', $metakeys ) ) {
65
- unset( $metakeys[ $searched ] );
66
- }
67
- if ( false !== $searched = array_search( $metakey . '_url', $metakeys ) ) {
68
- unset( $metakeys[ $searched ] );
69
- }
70
 
71
- global $wpdb;
72
 
73
- $wpdb->query( $wpdb->prepare(
74
- "DELETE FROM {$wpdb->prefix}um_metadata
75
- WHERE um_key = %s OR
76
- um_key = %s OR
77
- um_key = %s",
78
- $metakey . '_lat',
79
- $metakey . '_lng',
80
- $metakey . '_url'
81
- ) );
82
 
83
- update_option( 'um_usermeta_fields', array_values( $metakeys ) );
84
- }
85
- } else {
86
- if ( in_array( $metakey, $metakeys ) ) {
87
- unset( $metakeys[ array_search( $metakey, $metakeys ) ] );
88
-
89
- global $wpdb;
90
-
91
- $wpdb->delete(
92
- "{$wpdb->prefix}um_metadata",
93
- array(
94
- 'um_key' => $metakey
95
- ),
96
- array(
97
- '%s'
98
- )
99
- );
100
-
101
- update_option( 'um_usermeta_fields', array_values( $metakeys ) );
102
- }
103
  }
 
 
104
  }
105
 
106
 
@@ -113,32 +87,12 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
113
  function on_new_field_added( $metakey, $args ) {
114
  $metakeys = get_option( 'um_usermeta_fields', array() );
115
 
116
- if ( $args['type'] == 'user_location' ) {
117
- $update = false;
118
- if ( ! in_array( $metakey . '_lat', $metakeys ) ) {
119
- $update = true;
120
- $metakeys[] = $metakey . '_lat';
121
- }
122
-
123
- if ( ! in_array( $metakey . '_lng', $metakeys ) ) {
124
- $update = true;
125
- $metakeys[] = $metakey . '_lng';
126
- }
127
-
128
- if ( ! in_array( $metakey . '_url', $metakeys ) ) {
129
- $update = true;
130
- $metakeys[] = $metakey . '_url';
131
- }
132
-
133
- if ( $update ) {
134
- update_option( 'um_usermeta_fields', array_values( $metakeys ) );
135
- }
136
- } else {
137
- if ( ! in_array( $metakey, $metakeys ) ) {
138
- $metakeys[] = $metakey;
139
- update_option( 'um_usermeta_fields', array_values( $metakeys ) );
140
- }
141
  }
 
 
142
  }
143
 
144
 
@@ -291,7 +245,10 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
291
 
292
  $value = trim( stripslashes( $value ) );
293
 
294
- $this->where_clauses[] = $wpdb->prepare( "{$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value = %s", $field, $value );
 
 
 
295
 
296
  if ( ! $is_default ) {
297
  $this->custom_filters_in_query[ $field ] = $value;
56
  function on_delete_custom_field( $metakey, $args ) {
57
  $metakeys = get_option( 'um_usermeta_fields', array() );
58
 
59
+ if ( in_array( $metakey, $metakeys ) ) {
60
+ unset( $metakeys[ array_search( $metakey, $metakeys ) ] );
 
 
 
 
 
 
 
 
 
61
 
62
+ global $wpdb;
63
 
64
+ $wpdb->delete(
65
+ "{$wpdb->prefix}um_metadata",
66
+ array(
67
+ 'um_key' => $metakey
68
+ ),
69
+ array(
70
+ '%s'
71
+ )
72
+ );
73
 
74
+ update_option( 'um_usermeta_fields', array_values( $metakeys ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
+
77
+ do_action( 'um_metadata_on_delete_custom_field', $metakeys, $metakey, $args );
78
  }
79
 
80
 
87
  function on_new_field_added( $metakey, $args ) {
88
  $metakeys = get_option( 'um_usermeta_fields', array() );
89
 
90
+ if ( ! in_array( $metakey, $metakeys ) ) {
91
+ $metakeys[] = $metakey;
92
+ update_option( 'um_usermeta_fields', array_values( $metakeys ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
+
95
+ do_action( 'um_metadata_on_new_field_added', $metakeys, $metakey, $args );
96
  }
97
 
98
 
245
 
246
  $value = trim( stripslashes( $value ) );
247
 
248
+ $compare = apply_filters( 'um_members_directory_filter_text', '=', $field );
249
+ $value = apply_filters( 'um_members_directory_filter_text_meta_value', $value, $field );
250
+
251
+ $this->where_clauses[] = $wpdb->prepare( "{$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value {$compare} %s", $field, $value );
252
 
253
  if ( ! $is_default ) {
254
  $this->custom_filters_in_query[ $field ] = $value;
includes/core/class-member-directory.php CHANGED
@@ -687,7 +687,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
687
  <?php disabled( ! empty( $filter_from_url ) && in_array( $opt, $filter_from_url ) );
688
 
689
  if ( $admin ) {
690
- if ( is_string( $default_value ) ) {
691
  $default_value = array( $default_value );
692
  }
693
 
@@ -1596,13 +1596,12 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1596
  case 'text':
1597
 
1598
  $value = stripslashes( $value );
1599
-
1600
  $field_query = array(
1601
  'relation' => 'OR',
1602
  array(
1603
  'key' => $field,
1604
  'value' => trim( $value ),
1605
- 'compare' => 'LIKE',
1606
  ),
1607
  );
1608
 
@@ -1871,7 +1870,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1871
  $field_query = array(
1872
  'key' => $field,
1873
  'value' => $value,
1874
- 'compare' => '=',
1875
  );
1876
 
1877
  break;
@@ -2212,7 +2211,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
2212
  $dropdown_actions = $this->build_user_actions_list( $user_id );
2213
 
2214
  $actions = array();
2215
- $can_edit = UM()->roles()->um_current_user_can( 'edit', $user_id ) || UM()->roles()->um_user_can( 'can_edit_everyone' );
2216
 
2217
  // Replace hook 'um_members_just_after_name'
2218
  ob_start();
687
  <?php disabled( ! empty( $filter_from_url ) && in_array( $opt, $filter_from_url ) );
688
 
689
  if ( $admin ) {
690
+ if ( ! is_array( $default_value ) ) {
691
  $default_value = array( $default_value );
692
  }
693
 
1596
  case 'text':
1597
 
1598
  $value = stripslashes( $value );
 
1599
  $field_query = array(
1600
  'relation' => 'OR',
1601
  array(
1602
  'key' => $field,
1603
  'value' => trim( $value ),
1604
+ 'compare' => apply_filters( 'um_members_directory_filter_text', 'LIKE', $field )
1605
  ),
1606
  );
1607
 
1870
  $field_query = array(
1871
  'key' => $field,
1872
  'value' => $value,
1873
+ 'compare' => apply_filters( 'um_members_directory_filter_text', '=', $field ),
1874
  );
1875
 
1876
  break;
2211
  $dropdown_actions = $this->build_user_actions_list( $user_id );
2212
 
2213
  $actions = array();
2214
+ $can_edit = UM()->roles()->um_current_user_can( 'edit', $user_id );
2215
 
2216
  // Replace hook 'um_members_just_after_name'
2217
  ob_start();
includes/core/class-permalinks.php CHANGED
@@ -187,6 +187,11 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
187
  wp_die( __( 'This activation link is expired or have already been used.', 'ultimate-member' ) );
188
  }
189
 
 
 
 
 
 
190
  um_fetch_user( $user_id );
191
  UM()->user()->approve();
192
  um_reset_user();
187
  wp_die( __( 'This activation link is expired or have already been used.', 'ultimate-member' ) );
188
  }
189
 
190
+ $account_secret_hash_expiry = get_user_meta( $user_id, 'account_secret_hash_expiry', true );
191
+ if ( ! empty( $account_secret_hash_expiry ) && time() > $account_secret_hash_expiry ) {
192
+ wp_die( __( 'This activation link is expired.', 'ultimate-member' ) );
193
+ }
194
+
195
  um_fetch_user( $user_id );
196
  UM()->user()->approve();
197
  um_reset_user();
includes/core/class-profile.php CHANGED
@@ -101,7 +101,8 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
101
  1 => __( 'Guests only', 'ultimate-member' ),
102
  2 => __( 'Members only', 'ultimate-member' ),
103
  3 => __( 'Only the owner', 'ultimate-member' ),
104
- 4 => __( 'Specific roles', 'ultimate-member' ),
 
105
  );
106
 
107
  return $privacy;
@@ -227,6 +228,25 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
227
  }
228
  }
229
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
 
231
  default:
232
  $can_view = true;
@@ -322,10 +342,9 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
322
  } else {
323
  if ( ! empty( $tabs ) ) {
324
  foreach ( $tabs as $k => $tab ) {
325
- if ( ! empty( $tab['hidden'] ) ) {
326
- $this->active_tab = $k;
327
- break;
328
- }
329
  }
330
  }
331
  }
101
  1 => __( 'Guests only', 'ultimate-member' ),
102
  2 => __( 'Members only', 'ultimate-member' ),
103
  3 => __( 'Only the owner', 'ultimate-member' ),
104
+ 4 => __( 'Only specific roles', 'ultimate-member' ),
105
+ 5 => __( 'Owner and specific roles', 'ultimate-member' ),
106
  );
107
 
108
  return $privacy;
228
  }
229
  }
230
  break;
231
+ case 5:
232
+ if ( is_user_logged_in() ) {
233
+ // check profile owner if not - check privacy roles settings
234
+ $can_view = get_current_user_id() === $target_id;
235
+
236
+ if ( ! $can_view ) {
237
+ if ( isset( $tab_data['default_privacy'] ) ) {
238
+ $roles = isset( $tab_data['default_privacy_roles'] ) ? $tab_data['default_privacy_roles'] : array();
239
+ } else {
240
+ $roles = (array) UM()->options()->get( 'profile_tab_' . $tab . '_roles' );
241
+ }
242
+
243
+ $current_user_roles = um_user( 'roles' );
244
+ if ( ! empty( $current_user_roles ) && count( array_intersect( $current_user_roles, $roles ) ) > 0 ) {
245
+ $can_view = true;
246
+ }
247
+ }
248
+ }
249
+ break;
250
 
251
  default:
252
  $can_view = true;
342
  } else {
343
  if ( ! empty( $tabs ) ) {
344
  foreach ( $tabs as $k => $tab ) {
345
+ // set first tab in order
346
+ $this->active_tab = $k;
347
+ break;
 
348
  }
349
  }
350
  }
includes/core/class-roles-capabilities.php CHANGED
@@ -643,13 +643,18 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
643
  $return = 0;
644
  }
645
  } else {
646
- if ( ! um_user( 'can_edit_everyone' ) ) {
 
647
  $return = 0;
648
  } else {
649
- if ( um_user( 'can_edit_roles' ) && ( empty( $current_user_roles ) || count( array_intersect( $current_user_roles, um_user( 'can_edit_roles' ) ) ) <= 0 ) ) {
650
  $return = 0;
651
  } else {
652
- $return = 1;
 
 
 
 
653
  }
654
  }
655
  }
643
  $return = 0;
644
  }
645
  } else {
646
+
647
+ if ( ! um_user( 'can_access_private_profile' ) && UM()->user()->is_private_profile( $user_id ) ) {
648
  $return = 0;
649
  } else {
650
+ if ( ! um_user( 'can_edit_everyone' ) ) {
651
  $return = 0;
652
  } else {
653
+ if ( um_user( 'can_edit_roles' ) && ( empty( $current_user_roles ) || count( array_intersect( $current_user_roles, um_user( 'can_edit_roles' ) ) ) <= 0 ) ) {
654
+ $return = 0;
655
+ } else {
656
+ $return = 1;
657
+ }
658
  }
659
  }
660
  }
includes/core/class-user.php CHANGED
@@ -1336,6 +1336,13 @@ if ( ! class_exists( 'um\core\User' ) ) {
1336
 
1337
  $this->profile['account_secret_hash'] = UM()->validation()->generate();
1338
  $this->update_usermeta_info( 'account_secret_hash' );
 
 
 
 
 
 
 
1339
  /**
1340
  * UM hook
1341
  *
@@ -1436,6 +1443,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
1436
 
1437
  $this->set_status( 'approved' );
1438
  $this->delete_meta( 'account_secret_hash' );
 
1439
 
1440
  /**
1441
  * UM hook
1336
 
1337
  $this->profile['account_secret_hash'] = UM()->validation()->generate();
1338
  $this->update_usermeta_info( 'account_secret_hash' );
1339
+
1340
+ $expiry_time = UM()->options()->get( 'activation_link_expiry_time' );
1341
+ if ( ! empty( $expiry_time ) && is_numeric( $expiry_time ) ) {
1342
+ $this->profile['account_secret_hash_expiry'] = time() + $expiry_time;
1343
+ $this->update_usermeta_info( 'account_secret_hash_expiry' );
1344
+ }
1345
+
1346
  /**
1347
  * UM hook
1348
  *
1443
 
1444
  $this->set_status( 'approved' );
1445
  $this->delete_meta( 'account_secret_hash' );
1446
+ $this->delete_meta( 'account_secret_hash_expiry' );
1447
 
1448
  /**
1449
  * UM hook
includes/core/um-actions-account.php CHANGED
@@ -453,7 +453,7 @@ function um_before_account_notifications( $args = array() ) {
453
  $output = UM()->account()->get_tab_fields( 'notifications', $args );
454
  if ( substr_count( $output, '_enable_new_' ) ) { ?>
455
 
456
- <p><?php _e( 'Select what email notifications do you want to receive', 'ultimate-member' ); ?></p>
457
 
458
  <?php }
459
  }
453
  $output = UM()->account()->get_tab_fields( 'notifications', $args );
454
  if ( substr_count( $output, '_enable_new_' ) ) { ?>
455
 
456
+ <p><?php _e( 'Select what email notifications you want to receive', 'ultimate-member' ); ?></p>
457
 
458
  <?php }
459
  }
includes/core/um-actions-form.php CHANGED
@@ -106,14 +106,54 @@ add_action( 'um_submit_form_errors_hook__blockedwords', 'um_submit_form_errors_h
106
  * @param $args
107
  */
108
  function um_submit_form_errors_hook( $args ) {
109
- $form_id = $args['form_id'];
110
-
111
  $mode = $args['mode'];
112
 
113
- $fields = unserialize( $args['custom_fields'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  if ( $mode == 'register' ) {
116
 
 
117
  /**
118
  * UM hook
119
  *
@@ -137,6 +177,7 @@ function um_submit_form_errors_hook( $args ) {
137
 
138
  } elseif ( $mode == 'profile' ) {
139
 
 
140
  /**
141
  * UM hook
142
  *
@@ -158,50 +199,9 @@ function um_submit_form_errors_hook( $args ) {
158
  */
159
  do_action( 'um_submit_form_errors_hook__profile', $args );
160
 
161
- }
162
 
163
- /**
164
- * UM hook
165
- *
166
- * @type action
167
- * @title um_submit_form_errors_hook__blockedips
168
- * @description Submit form validation
169
- * @input_vars
170
- * [{"var":"$args","type":"array","desc":"Form Arguments"}]
171
- * @change_log
172
- * ["Since: 2.0"]
173
- * @usage add_action( 'um_submit_form_errors_hook__blockedips', 'function_name', 10, 1 );
174
- * @example
175
- * <?php
176
- * add_action( 'um_submit_form_errors_hook__blockedips', 'my_submit_form_errors_hook__blockedips', 10, 1 );
177
- * function my_submit_form_errors_hook__blockedips( $args ) {
178
- * // your code here
179
- * }
180
- * ?>
181
- */
182
- do_action( 'um_submit_form_errors_hook__blockedips', $args );
183
- /**
184
- * UM hook
185
- *
186
- * @type action
187
- * @title um_submit_form_errors_hook__blockedemails
188
- * @description Submit form validation
189
- * @input_vars
190
- * [{"var":"$args","type":"array","desc":"Form Arguments"}]
191
- * @change_log
192
- * ["Since: 2.0"]
193
- * @usage add_action( 'um_submit_form_errors_hook__blockedemails', 'function_name', 10, 1 );
194
- * @example
195
- * <?php
196
- * add_action( 'um_submit_form_errors_hook__blockedemails', 'my_submit_form_errors_hook__blockedemails', 10, 1 );
197
- * function my_submit_form_errors_hook__blockedemails( $args ) {
198
- * // your code here
199
- * }
200
- * ?>
201
- */
202
- do_action( 'um_submit_form_errors_hook__blockedemails', $args );
203
 
204
- if ( $mode == 'login' ) {
205
  /**
206
  * UM hook
207
  *
@@ -222,6 +222,8 @@ function um_submit_form_errors_hook( $args ) {
222
  * ?>
223
  */
224
  do_action( 'um_submit_form_errors_hook_login', $args );
 
 
225
  /**
226
  * UM hook
227
  *
@@ -243,47 +245,54 @@ function um_submit_form_errors_hook( $args ) {
243
  */
244
  do_action( 'um_submit_form_errors_hook_logincheck', $args );
245
 
246
- } else {
 
 
 
 
 
247
  /**
248
  * UM hook
249
  *
250
  * @type action
251
- * @title um_submit_form_errors_hook_
252
  * @description Submit form validation
253
  * @input_vars
254
  * [{"var":"$args","type":"array","desc":"Form Arguments"}]
255
  * @change_log
256
  * ["Since: 2.0"]
257
- * @usage add_action( 'um_submit_form_errors_hook_', 'function_name', 10, 1 );
258
  * @example
259
  * <?php
260
- * add_action( 'um_submit_form_errors_hook_', 'my_submit_form_errors_hook', 10, 1 );
261
- * function my_submit_form_errors_hook( $args ) {
262
  * // your code here
263
  * }
264
  * ?>
265
  */
266
- do_action( 'um_submit_form_errors_hook_', $args );
 
 
267
  /**
268
  * UM hook
269
  *
270
  * @type action
271
- * @title um_submit_form_errors_hook__blockedwords
272
  * @description Submit form validation
273
  * @input_vars
274
  * [{"var":"$args","type":"array","desc":"Form Arguments"}]
275
  * @change_log
276
  * ["Since: 2.0"]
277
- * @usage add_action( 'um_submit_form_errors_hook__blockedwords', 'function_name', 10, 1 );
278
  * @example
279
  * <?php
280
- * add_action( 'um_submit_form_errors_hook__blockedwords', 'my_submit_form_errors_hook__blockedwords', 10, 1 );
281
- * function my_submit_form_errors_hook__blockedwords( $args ) {
282
  * // your code here
283
  * }
284
  * ?>
285
  */
286
- do_action( 'um_submit_form_errors_hook__blockedwords', $args );
287
 
288
  }
289
 
@@ -411,13 +420,25 @@ function um_submit_form_errors_hook_( $args ) {
411
  $form_id = $args['form_id'];
412
  $mode = $args['mode'];
413
  $fields = unserialize( $args['custom_fields'] );
414
- $um_profile_photo = um_profile('profile_photo');
415
 
 
416
  if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && ( empty( $args['profile_photo'] ) && empty( $um_profile_photo ) ) ) {
417
  UM()->form()->add_error('profile_photo', __( 'Profile Photo is required.', 'ultimate-member' ) );
418
  }
419
 
420
  if ( ! empty( $fields ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
421
  foreach ( $fields as $key => $array ) {
422
 
423
  if ( $mode == 'profile' ) {
@@ -427,13 +448,52 @@ function um_submit_form_errors_hook_( $args ) {
427
  }
428
  }
429
 
430
- if ( isset( $array['public'] ) && -2 == $array['public'] && ! empty( $array['roles'] ) && is_user_logged_in() ) {
431
- $current_user_roles = um_user( 'roles' );
432
- if ( empty( $current_user_roles ) || count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
433
- continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
  }
 
435
  }
436
 
 
 
 
 
 
 
 
437
  /**
438
  * UM hook
439
  *
106
  * @param $args
107
  */
108
  function um_submit_form_errors_hook( $args ) {
 
 
109
  $mode = $args['mode'];
110
 
111
+ /**
112
+ * UM hook
113
+ *
114
+ * @type action
115
+ * @title um_submit_form_errors_hook__blockedips
116
+ * @description Submit form validation
117
+ * @input_vars
118
+ * [{"var":"$args","type":"array","desc":"Form Arguments"}]
119
+ * @change_log
120
+ * ["Since: 2.0"]
121
+ * @usage add_action( 'um_submit_form_errors_hook__blockedips', 'function_name', 10, 1 );
122
+ * @example
123
+ * <?php
124
+ * add_action( 'um_submit_form_errors_hook__blockedips', 'my_submit_form_errors_hook__blockedips', 10, 1 );
125
+ * function my_submit_form_errors_hook__blockedips( $args ) {
126
+ * // your code here
127
+ * }
128
+ * ?>
129
+ */
130
+ do_action( 'um_submit_form_errors_hook__blockedips', $args );
131
+
132
+
133
+ /**
134
+ * UM hook
135
+ *
136
+ * @type action
137
+ * @title um_submit_form_errors_hook__blockedemails
138
+ * @description Submit form validation
139
+ * @input_vars
140
+ * [{"var":"$args","type":"array","desc":"Form Arguments"}]
141
+ * @change_log
142
+ * ["Since: 2.0"]
143
+ * @usage add_action( 'um_submit_form_errors_hook__blockedemails', 'function_name', 10, 1 );
144
+ * @example
145
+ * <?php
146
+ * add_action( 'um_submit_form_errors_hook__blockedemails', 'my_submit_form_errors_hook__blockedemails', 10, 1 );
147
+ * function my_submit_form_errors_hook__blockedemails( $args ) {
148
+ * // your code here
149
+ * }
150
+ * ?>
151
+ */
152
+ do_action( 'um_submit_form_errors_hook__blockedemails', $args );
153
 
154
  if ( $mode == 'register' ) {
155
 
156
+
157
  /**
158
  * UM hook
159
  *
177
 
178
  } elseif ( $mode == 'profile' ) {
179
 
180
+
181
  /**
182
  * UM hook
183
  *
199
  */
200
  do_action( 'um_submit_form_errors_hook__profile', $args );
201
 
202
+ } elseif ( $mode == 'login' ) {
203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
 
205
  /**
206
  * UM hook
207
  *
222
  * ?>
223
  */
224
  do_action( 'um_submit_form_errors_hook_login', $args );
225
+
226
+
227
  /**
228
  * UM hook
229
  *
245
  */
246
  do_action( 'um_submit_form_errors_hook_logincheck', $args );
247
 
248
+ }
249
+
250
+
251
+ if ( $mode != 'login' ) {
252
+
253
+
254
  /**
255
  * UM hook
256
  *
257
  * @type action
258
+ * @title um_submit_form_errors_hook__blockedwords
259
  * @description Submit form validation
260
  * @input_vars
261
  * [{"var":"$args","type":"array","desc":"Form Arguments"}]
262
  * @change_log
263
  * ["Since: 2.0"]
264
+ * @usage add_action( 'um_submit_form_errors_hook__blockedwords', 'function_name', 10, 1 );
265
  * @example
266
  * <?php
267
+ * add_action( 'um_submit_form_errors_hook__blockedwords', 'my_submit_form_errors_hook__blockedwords', 10, 1 );
268
+ * function my_submit_form_errors_hook__blockedwords( $args ) {
269
  * // your code here
270
  * }
271
  * ?>
272
  */
273
+ do_action( 'um_submit_form_errors_hook__blockedwords', $args );
274
+
275
+
276
  /**
277
  * UM hook
278
  *
279
  * @type action
280
+ * @title um_submit_form_errors_hook_
281
  * @description Submit form validation
282
  * @input_vars
283
  * [{"var":"$args","type":"array","desc":"Form Arguments"}]
284
  * @change_log
285
  * ["Since: 2.0"]
286
+ * @usage add_action( 'um_submit_form_errors_hook_', 'function_name', 10, 1 );
287
  * @example
288
  * <?php
289
+ * add_action( 'um_submit_form_errors_hook_', 'my_submit_form_errors_hook', 10, 1 );
290
+ * function my_submit_form_errors_hook( $args ) {
291
  * // your code here
292
  * }
293
  * ?>
294
  */
295
+ do_action( 'um_submit_form_errors_hook_', $args );
296
 
297
  }
298
 
420
  $form_id = $args['form_id'];
421
  $mode = $args['mode'];
422
  $fields = unserialize( $args['custom_fields'] );
 
423
 
424
+ $um_profile_photo = um_profile('profile_photo');
425
  if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && ( empty( $args['profile_photo'] ) && empty( $um_profile_photo ) ) ) {
426
  UM()->form()->add_error('profile_photo', __( 'Profile Photo is required.', 'ultimate-member' ) );
427
  }
428
 
429
  if ( ! empty( $fields ) ) {
430
+
431
+ $can_edit = false;
432
+ $current_user_roles = [];
433
+ if ( is_user_logged_in() ) {
434
+
435
+ $can_edit = UM()->roles()->um_current_user_can( 'edit', $args['user_id'] );
436
+
437
+ um_fetch_user( get_current_user_id() );
438
+ $current_user_roles = um_user( 'roles' );
439
+ um_reset_user();
440
+ }
441
+
442
  foreach ( $fields as $key => $array ) {
443
 
444
  if ( $mode == 'profile' ) {
448
  }
449
  }
450
 
451
+ $can_view = true;
452
+ if ( isset( $array['public'] ) && $mode != 'register' ) {
453
+
454
+ switch ( $array['public'] ) {
455
+ case '1': // Everyone
456
+ break;
457
+ case '2': // Members
458
+ if ( ! is_user_logged_in() ) {
459
+ $can_view = false;
460
+ }
461
+ break;
462
+ case '-1': // Only visible to profile owner and admins
463
+ if ( ! is_user_logged_in() ) {
464
+ $can_view = false;
465
+ } elseif ( $args['user_id'] != get_current_user_id() && ! $can_edit ) {
466
+ $can_view = false;
467
+ }
468
+ break;
469
+ case '-2': // Only specific member roles
470
+ if ( ! is_user_logged_in() ) {
471
+ $can_view = false;
472
+ } elseif ( ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
473
+ $can_view = false;
474
+ }
475
+ break;
476
+ case '-3': // Only visible to profile owner and specific roles
477
+ if ( ! is_user_logged_in() ) {
478
+ $can_view = false;
479
+ } elseif ( $args['user_id'] != get_current_user_id() && ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
480
+ $can_view = false;
481
+ }
482
+ break;
483
+ default:
484
+ $can_view = apply_filters( 'um_can_view_field_custom', $can_view, $array );
485
+ break;
486
  }
487
+
488
  }
489
 
490
+ $can_view = apply_filters( 'um_can_view_field', $can_view, $array );
491
+
492
+ if ( ! $can_view ) {
493
+ continue;
494
+ }
495
+
496
+
497
  /**
498
  * UM hook
499
  *
includes/core/um-actions-login.php CHANGED
@@ -75,7 +75,7 @@ function um_submit_form_errors_hook_login( $args ) {
75
 
76
  // if there is an error notify wp
77
  if ( UM()->form()->has_error( $field ) || UM()->form()->has_error( $user_password ) || UM()->form()->count_errors() > 0 ) {
78
- do_action( 'wp_login_failed', $user_name );
79
  }
80
  }
81
  add_action( 'um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_login', 10 );
75
 
76
  // if there is an error notify wp
77
  if ( UM()->form()->has_error( $field ) || UM()->form()->has_error( $user_password ) || UM()->form()->count_errors() > 0 ) {
78
+ do_action( 'wp_login_failed', $user_name, UM()->form()->errors );
79
  }
80
  }
81
  add_action( 'um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_login', 10 );
includes/core/um-actions-profile.php CHANGED
@@ -1294,42 +1294,38 @@ function um_pre_profile_shortcode( $args ) {
1294
  */
1295
  extract( $args );
1296
 
1297
- if ( $mode == 'profile' && UM()->fields()->editing == false ) {
1298
- UM()->fields()->viewing = 1;
1299
-
1300
- if ( um_get_requested_user() ) {
1301
- if ( ! um_can_view_profile( um_get_requested_user() ) && ! um_is_myprofile() ) {
1302
- um_redirect_home( um_get_requested_user(), um_is_myprofile() );
1303
- }
1304
-
1305
- if ( ! UM()->roles()->um_current_user_can( 'edit', um_get_requested_user() ) ) {
1306
- UM()->user()->cannot_edit = 1;
1307
  }
1308
-
1309
- um_fetch_user( um_get_requested_user() );
1310
  } else {
1311
- if ( ! is_user_logged_in() ) {
1312
- um_redirect_home( um_get_requested_user(), um_is_myprofile() );
1313
- }
1314
 
1315
- if ( ! um_user( 'can_edit_profile' ) ) {
1316
- UM()->user()->cannot_edit = 1;
1317
- }
1318
- }
1319
- }
 
 
 
1320
 
1321
- if ( $mode == 'profile' && UM()->fields()->editing == true ) {
1322
- UM()->fields()->editing = 1;
 
 
 
1323
 
1324
- if ( um_get_requested_user() ) {
1325
- if ( ! UM()->roles()->um_current_user_can( 'edit', um_get_requested_user() ) ) {
1326
- um_redirect_home( um_get_requested_user(), um_is_myprofile() );
1327
  }
1328
- um_fetch_user( um_get_requested_user() );
1329
  }
1330
-
1331
  }
1332
-
1333
  }
1334
  add_action( 'um_pre_profile_shortcode', 'um_pre_profile_shortcode' );
1335
 
1294
  */
1295
  extract( $args );
1296
 
1297
+ if ( $mode == 'profile' ) {
1298
+ if ( UM()->fields()->editing ) {
1299
+ if ( um_get_requested_user() ) {
1300
+ if ( ! UM()->roles()->um_current_user_can( 'edit', um_get_requested_user() ) ) {
1301
+ um_redirect_home( um_get_requested_user(), um_is_myprofile() );
1302
+ }
1303
+ um_fetch_user( um_get_requested_user() );
 
 
 
1304
  }
 
 
1305
  } else {
1306
+ UM()->fields()->viewing = 1;
 
 
1307
 
1308
+ if ( um_get_requested_user() ) {
1309
+ if ( ! um_can_view_profile( um_get_requested_user() ) && ! um_is_myprofile() ) {
1310
+ um_redirect_home( um_get_requested_user(), um_is_myprofile() );
1311
+ }
1312
+
1313
+ if ( ! UM()->roles()->um_current_user_can( 'edit', um_get_requested_user() ) ) {
1314
+ UM()->user()->cannot_edit = 1;
1315
+ }
1316
 
1317
+ um_fetch_user( um_get_requested_user() );
1318
+ } else {
1319
+ if ( ! is_user_logged_in() ) {
1320
+ um_redirect_home( um_get_requested_user(), um_is_myprofile() );
1321
+ }
1322
 
1323
+ if ( ! um_user( 'can_edit_profile' ) ) {
1324
+ UM()->user()->cannot_edit = 1;
1325
+ }
1326
  }
 
1327
  }
 
1328
  }
 
1329
  }
1330
  add_action( 'um_pre_profile_shortcode', 'um_pre_profile_shortcode' );
1331
 
includes/um-short-functions.php CHANGED
@@ -1514,7 +1514,12 @@ function um_can_view_field( $data ) {
1514
 
1515
  if ( isset( $data['public'] ) && UM()->fields()->set_mode != 'register' ) {
1516
 
 
 
1517
  if ( is_user_logged_in() ) {
 
 
 
1518
  $previous_user = um_user( 'ID' );
1519
  um_fetch_user( get_current_user_id() );
1520
 
@@ -1523,47 +1528,32 @@ function um_can_view_field( $data ) {
1523
  }
1524
 
1525
  switch ( $data['public'] ) {
1526
- case '1':
1527
- $can_view = true;
1528
  break;
1529
- case '2':
1530
  if ( ! is_user_logged_in() ) {
1531
  $can_view = false;
1532
  }
1533
  break;
1534
- case '-1':
1535
  if ( ! is_user_logged_in() ) {
1536
  $can_view = false;
1537
- } else {
1538
- if ( ! um_is_user_himself() && ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
1539
- $can_view = false;
1540
- }
1541
  }
1542
  break;
1543
- case '-2':
1544
  if ( ! is_user_logged_in() ) {
1545
  $can_view = false;
1546
- } else {
1547
- if ( ! empty( $data['roles'] ) ) {
1548
- if ( empty( $current_user_roles ) || count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 ) {
1549
- $can_view = false;
1550
- }
1551
- }
1552
  }
1553
  break;
1554
- case '-3':
1555
  if ( ! is_user_logged_in() ) {
1556
  $can_view = false;
1557
- } else {
1558
- if ( ! um_is_core_page( 'profile' ) ) {
1559
- if ( empty( $current_user_roles ) || ( ! empty( $data['roles'] ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 ) ) {
1560
- $can_view = false;
1561
- }
1562
- } else {
1563
- if ( ! um_is_user_himself() && ( empty( $current_user_roles ) || ( ! empty( $data['roles'] ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 ) ) ) {
1564
- $can_view = false;
1565
- }
1566
- }
1567
  }
1568
  break;
1569
  default:
@@ -1585,10 +1575,6 @@ function um_can_view_field( $data ) {
1585
  * @return bool
1586
  */
1587
  function um_can_view_profile( $user_id ) {
1588
- if ( UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
1589
- return true;
1590
- }
1591
-
1592
  if ( ! is_user_logged_in() ) {
1593
  return ! UM()->user()->is_private_profile( $user_id );
1594
  }
@@ -1618,6 +1604,7 @@ function um_can_view_profile( $user_id ) {
1618
  return false;
1619
  }
1620
  }
 
1621
  um_fetch_user( $temp_id );
1622
  return true;
1623
  }
1514
 
1515
  if ( isset( $data['public'] ) && UM()->fields()->set_mode != 'register' ) {
1516
 
1517
+ $can_edit = false;
1518
+ $current_user_roles = [];
1519
  if ( is_user_logged_in() ) {
1520
+
1521
+ $can_edit = UM()->roles()->um_current_user_can( 'edit', um_user( 'ID' ) );
1522
+
1523
  $previous_user = um_user( 'ID' );
1524
  um_fetch_user( get_current_user_id() );
1525
 
1528
  }
1529
 
1530
  switch ( $data['public'] ) {
1531
+ case '1': // Everyone
 
1532
  break;
1533
+ case '2': // Members
1534
  if ( ! is_user_logged_in() ) {
1535
  $can_view = false;
1536
  }
1537
  break;
1538
+ case '-1': // Only visible to profile owner and users who can edit other member accounts
1539
  if ( ! is_user_logged_in() ) {
1540
  $can_view = false;
1541
+ } elseif ( ! um_is_user_himself() && ! $can_edit ) {
1542
+ $can_view = false;
 
 
1543
  }
1544
  break;
1545
+ case '-2': // Only specific member roles
1546
  if ( ! is_user_logged_in() ) {
1547
  $can_view = false;
1548
+ } elseif ( ! empty( $data['roles'] ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 ) {
1549
+ $can_view = false;
 
 
 
 
1550
  }
1551
  break;
1552
+ case '-3': // Only visible to profile owner and specific roles
1553
  if ( ! is_user_logged_in() ) {
1554
  $can_view = false;
1555
+ } elseif ( ! um_is_user_himself() && ! empty( $data['roles'] ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 ) {
1556
+ $can_view = false;
 
 
 
 
 
 
 
 
1557
  }
1558
  break;
1559
  default:
1575
  * @return bool
1576
  */
1577
  function um_can_view_profile( $user_id ) {
 
 
 
 
1578
  if ( ! is_user_logged_in() ) {
1579
  return ! UM()->user()->is_private_profile( $user_id );
1580
  }
1604
  return false;
1605
  }
1606
  }
1607
+
1608
  um_fetch_user( $temp_id );
1609
  return true;
1610
  }
readme.txt CHANGED
@@ -7,7 +7,7 @@ Tags: community, member, membership, user-profile, user-registration
7
  Requires PHP: 5.6
8
  Requires at least: 5.0
9
  Tested up to: 5.7
10
- Stable tag: 2.1.16
11
  License: GNU Version 2 or Any Later Version
12
  License URI: http://www.gnu.org/licenses/gpl-3.0.txt
13
 
@@ -155,6 +155,30 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
155
  * To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
156
  * UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  = 2.1.16: March 10, 2021 =
159
 
160
  * Enhancements:
7
  Requires PHP: 5.6
8
  Requires at least: 5.0
9
  Tested up to: 5.7
10
+ Stable tag: 2.1.17
11
  License: GNU Version 2 or Any Later Version
12
  License URI: http://www.gnu.org/licenses/gpl-3.0.txt
13
 
155
  * To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
156
  * UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
157
 
158
+ = 2.1.17: April 14, 2021 =
159
+
160
+ * Enhancements:
161
+ - Added: Activation link expiration setting (#803)
162
+ - Added: 'Owner and specific roles' privacy type for the Profile tabs (#773)
163
+ - Added: Hooks `um_before_email_notification_sending` and `um_after_email_notification_sending` regarding #743 pull-request
164
+ - Added: Hooks for integration member directory filters with different conditions for query to DB
165
+
166
+ * Bugfixes:
167
+ - Fixed: Editing private profiles capability. Removed the priority for "Can edit other member accounts?" capability when the account is private. (#805)
168
+ - Fixed: PHP notice when the admin filtering field has the not array default value (e.g. bool)
169
+ - Fixed: The conflict with [Disable Blog](https://wordpress.org/plugins/disable-blog/) plugin regarding this [issue](https://wordpress.org/support/topic/ultimate-member-file-image-download/). `download_routing` callback has the highest priority now.
170
+ - Fixed: Fields privacy functionality. This function `um_can_view_field()` has been rewritten (#780)
171
+ - Fixed: Fields privacy + form validation functionality. Skip the field's validation that aren't visible on the form based on the privacy settings (#795)
172
+ - Fixed: PHP notice in the confirm password label [wp.org thread](https://wordpress.org/support/topic/undefined-index-label-php-notice/)
173
+ - Fixed: Confirm password placeholder when label is empty
174
+ - Fixed: Permanently deleting form's field (#786)
175
+ - Fixed: Default value with comma for checkbox field-type (#729)
176
+ - Fixed: Gutenberg blocks conditional settings (#793)
177
+ - Fixed: Getting active Profile tab when some of them are hidden
178
+ - Fixed: Restricted content message is showing twice and removing header, avoid the conflicts with themes that use 'the_content' filter in header or footer (#799)
179
+ - Fixed: "Is required" validation for the multiselect field-type when it's empty on submit
180
+ - Fixed: Using 'wp_login_failed' hook, added 2nd parameter required since WordPress 5.4 version (#810)
181
+
182
  = 2.1.16: March 10, 2021 =
183
 
184
  * Enhancements:
ultimate-member.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Ultimate Member
4
  Plugin URI: http://ultimatemember.com/
5
  Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
6
- Version: 2.1.16
7
  Author: Ultimate Member
8
  Author URI: http://ultimatemember.com/
9
  Text Domain: ultimate-member
3
  Plugin Name: Ultimate Member
4
  Plugin URI: http://ultimatemember.com/
5
  Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
6
+ Version: 2.1.17
7
  Author: Ultimate Member
8
  Author URI: http://ultimatemember.com/
9
  Text Domain: ultimate-member