• Resolved WPSOLR

    (@wpsolr)


    Hi,

    I’m getting an issue while adding groups capabilities as a filter to Solr search, so users can see only their authorized content.

    I created a group ‘sol_group1’, to which I added a capability ‘solr_capability1’
    I added ‘sol_group1’ to my WP user profile.

    But when I execute:

    $groups_user = new Groups_User( get_current_user_id() );
    $user_capabilities = $groups_user->__get( 'capabilities' );

    I get nothing.

    The table wp_groups_user_capability is empty also.

    I noticed that this works:

    $groups_user = new Groups_User( get_current_user_id() );
    $user_groups = $groups_user->__get( 'groups' );
Viewing 1 replies (of 1 total)
  • Thread Starter WPSOLR

    (@wpsolr)

    Here is my workaround, if no one can propose a ready-made solution

    // Fetch current user's groups
    $groups_user = new Groups_User( get_current_user_id() );
    $groups      = $groups_user->__get( Groups_User::CACHE_GROUP );
    
    // Fetch capabilities of current user's groups
    $capabilities = array();
    if ( isset( $groups ) ) {
    
    	foreach ( $groups as $group ) {
    
    		if ( isset( $group ) ) {
    
    			$group_capabilities = $group->__get( Groups_User::CAPABILITIES );
    
    			if ( isset( $group_capabilities ) ) {
    
    				foreach ( $group_capabilities as $group_capability ) {
    
    					if ( isset( $group_capability ) && isset( $group_capability->capability ) ) {
    
    						$capabilities[] = $group_capability->capability->capability;
    					}
    				}
    			}
    		}
    	}
    }
Viewing 1 replies (of 1 total)

The topic ‘Adding groups to WPSOLR search plugin’ is closed to new replies.