Change WordPress user roles and capabilities › Forums › Restrict or Permit access inside WordPress – how to › If no restrictions, user sees everything
- This topic has 5 replies, 2 voices, and was last updated 8 years, 2 months ago by Vladimir.
-
AuthorPosts
-
27/07/2016 at 13:11 #2579NewCollege CommunicationsParticipant
this is moved over from https://wordpress.org/support/topic/if-no-restrictions-user-sees-everything?replies=3#post-8685810
Thank you for your reply and again, I am sorry for posting in the public space.
Would it be possible to modify the user’s meta at run time so that if the user does not have a category set, I can set it to 999999999? Is there a hook for in the vicinity of the functionality that checks this?
27/07/2016 at 14:03 #2580VladimirKeymasterNo problem.
The only custom filter which is currently included to URE’s code related to the edit restrictions items at user level is ‘ure_post_edit_access_authors_list’.
$value = apply_filters('ure_post_edit_access_authors_list', $value);
I will add more custom filters with a next version possibly.
You may use a general WordPress ‘get_user_metadata’ filter from get_meta_data() function:
$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single );
Here:
$object_id : $current_user->ID,
$meta_key : $wpdb->prefix .’ure_categories_list’In both cases you should check if you set the category for this user or not yourself inside those filters.
27/07/2016 at 14:05 #2581NewCollege CommunicationsParticipantperfect. I will give it a try
27/07/2016 at 16:37 #2583NewCollege CommunicationsParticipantI ended up with
function filter_users_for_no_community($null,$object_id,$meta_key,$single){ global $wpdb; $theMeta = $wpdb->prefix . 'ure_categories_list'; if($theMeta === $meta_key){ remove_filter( 'get_user_metadata', 'filter_users_for_no_community', 10 , 4 ); $cats = get_user_meta($object_id,$meta_key,$single); add_filter( 'get_user_metadata', 'filter_users_for_no_community', 10 , 4 ); if(!$cats){ $value = '99999999'; } } return $value; } add_filter( 'get_user_metadata', 'filter_users_for_no_community', 10 , 4 );
thanks for your help
30/08/2016 at 16:58 #2682NewCollege CommunicationsParticipantcoming back to this after debugging a bit. I would nix the above code if you see a bunch of 502 errors.
31/08/2016 at 01:12 #2685VladimirKeymasterIf such filter ends with high server load, another workaround is to use an additional role for no-community users instead of work with every user meta data. If you allow that no-community role with access to unexisted post, like ID 99999999, users with that role will see an empty posts list.
From my side I will look if I may add to URE own custom filter to change a default behaviour of edit restrictions add-on. So if you set such filter then all users without restrictions will see nothing.
-
AuthorPosts
- You must be logged in to reply to this topic.