Home Forums Plugin Support WP User Frontend Pro [WPUF User Listing]Viewer Role filters not working

This topic is: resolved

This topic contains 24 replies, has 2 voices, and was last updated by  Nayem 3 years, 9 months ago.

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #67048

    MareVisie
    Member
    Post count: 83

    I have bought the extention WPUF User Listing. However, the filters that I apply for Viewer Role (Show this field if the viewer (current logged in user or guest) has one of these role.) don't seem to work.

    #67357

    Nayem
    Moderator
    Post count: 6480

    Hello MareVise,

    I am really sorry for being late. Can you please provide any screenshot?

    #67565

    MareVisie
    Member
    Post count: 83

    Hi Nayem,

    Here's the User Listing section in the admin menu:

    And here's what I see with the admin account (administrator role) in the frontend:

    #67684

    Nayem
    Moderator
    Post count: 6480

    Actually your screenshot does not describe the issue correctly. Can you please tell me the scenario?

    #67751

    MareVisie
    Member
    Post count: 83

    What I am trying to do is have information in the user listing profiles that is only visible by users with certain user roles. In order to do so the plugin offers Viewer role capabilities. Each meta field has checkboxes where you can hide fields from certain user roles. In the screenshots above I unchecked the two fields for the administrator role, meaning that the two fields can't be seen on profile pages by users with an Administrator user role. However, when I log in as administrator and visit a profile page, the (supposed to be hidden) fields show up anyway.

    #67754

    Nayem
    Moderator
    Post count: 6480

    Please provide your login details by using this form: http://wedevs.com/provide-login-details/. I will have a look what is going wrong.

    Thank you ๐Ÿ™‚

    #67755

    MareVisie
    Member
    Post count: 83

    Done.

    #67778

    Nayem
    Moderator
    Post count: 6480

    Hello,

    I got your details. Please allow us some time to check.

    Thanks.

    #68300

    Nayem
    Moderator
    Post count: 6480

    Please check your site now.

    Thanks.

    #69010

    MareVisie
    Member
    Post count: 83

    Hi Nayem,

    It works now, but only for Primary roles. Is it possible to have it filter on ALL assigned user roles?

    #69011

    Nayem
    Moderator
    Post count: 6480

    Hello,

    It is possible but you have to customize the plugin for that.

    Thanks.

    #69031

    MareVisie
    Member
    Post count: 83

    Could you point me in the right direction? Where can I find the code that does this?

    #69082

    Nayem
    Moderator
    Post count: 6480

    Hello,

    Please open wpuf-profile-filed folder/userlisting-admin.php file. In this file you will get this function- function user_role_template(). You have to customize here.

    Thanks.

    #69115

    MareVisie
    Member
    Post count: 83

    Isn't the function can_user_see in wpuf-user-listing/userlisting.php controlling what users actually get to see?

    #69119

    MareVisie
    Member
    Post count: 83

    I changed the function to this:

    
       public static function can_user_see( $profile_role, $field, $user_role ) {
    
            // bail out if the current user role is not in the list
            if ( !in_array( $profile_role, $field['all_user_role'] ) ) {
                return false;
            }
    
            // check viewer role
    		global $current_user;
    		$current_user_roles = $current_user->roles;
    		foreach($current_user_roles as $cur){
    			
    			if ( !in_array( $cur, $field['current_user_role'] ) ) {
    				continue;
    			} else {
    				return true;
    			};
    			
    		};
            return false;
        }
    

    It's now doing what I want it to do. Do you think it is safe to implement online? Will it mess with what you did in my admin panel?

Viewing 15 posts - 1 through 15 (of 25 total)

The topic ‘[WPUF User Listing]Viewer Role filters not working’ is closed to new replies.