Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • I had the same error message, and got it working eventually. I have a different server setup though (Rasbian/gninx/php/mysql). But some of the following might apply for others as well.

    • Make sure www-data (or the user your script is running under) has a SSH key (without password), and that it is added to your bitbucket/github account. ssh-keygen
    • Make sure that the .git directory in your repositories root folder has the correct permissions, as well as some of the files in it. The www-data user needs writing permissions. Note: the .git directory is hidden. Check its permissions with ls /var/www/.git -la. Set permissions recursively with chmod -R 770 /var/www/.git
    • Do an initial push to remote from the commandline, as www-data user. The first time ssh will say the rsa fingerprint of the remote server is unknown, and asks you to add it permanently.
    arjenbreur

    (@arjenbreur)

    I had the same (or similar?) problem.
    After restricting content for users through User Access Manager, the pagination isn’t functioning correctly. While my frontpage is set to 10 posts per page, some users get to see less or even no posts.

    Davoron pinpointed the problem precisely: 10 posts are retrieved from the database, but before they are shown, the restricted posts are filtered out, leaving less or no posts to show.

    The main query should already leave out the restricted posts. I added a filter to achieve this.

    But that’s not all. There is also a problem with the method ‘getPostsForUser‘. It is only retrieving posts of the type ‘post’. That needs to be fixed too, in order to have pagination work with custom post types.
    Sidenote: Big thanks to Davonon, for pointing me in the right direction: ‘getExcludedPosts‘ isn’t returning any posts (at least not in the case of this issue), but that is because it relies on the faulty getPostsForUser.

    I fixed this problem by changing the plugins code in several places.

    Add this to class/UamAccessHandler.class.php:

    /**
         * MY FIX TO MAKE PAGINATION WORK WITH CUSTOM POST TYPES
         *
         * @param arrray $query The query object
         *
         * @return void, $query is passed by refecence
         */
    	function AB_pre_get_posts( $query ) {
    	    if ( is_admin() || ! $query->is_main_query() )
    	        return;
    
            $uamAccessHandler = &$this->getAccessHandler();
    
    		$usersPosts = $uamAccessHandler->getPostsForUser();
    		$query->query_vars['post__in'] = array_merge(
    			$query->query_vars['post__in'],
    			$usersPosts
    		);
    		return;
    	}

    Trigger this method by adding a hook in user-access-manager.php, around line 340:

    //MY FIX TO MAKE PAGINATION WORK WITH CUSTOM POST TYPES
            add_filter('pre_get_posts', array(&$userAccessManager, 'AB_pre_get_posts'));

    Now we only need to change the faulty getPostsForUser method by changing class/UamAccessHandler.class.php. Find the method (around line 530), and change the following code:

    // MY FIX TO MAKE PAGINATION WORK WITH CUSTOM POST TYPES
    // REMOVED:
    //         $postAssignedToUserSql = "
    //         	 SELECT igp.object_id
    //         	 FROM ".DB_ACCESSGROUP_TO_OBJECT." AS igp
    //         	 WHERE igp.object_type = 'post'
    //          AND igp.group_id IN (".$userUserGroupString.")";
    // ADDED:
            $postableTypes = $this->getPostableTypes();
            $postableTypesString = "'".implode("','", $postableTypes)."'";
            $postAssignedToUserSql = "
            	 SELECT igp.object_id
            	 FROM ".DB_ACCESSGROUP_TO_OBJECT." AS igp
            	 WHERE igp.object_type IN ( ".$postableTypesString." )
             AND igp.group_id IN (".$userUserGroupString.")";

    For me this did the trick. Be aware that on an update of the plugin, these changes will be lost (although hopefully the problem might be fixed by the update). Hope it works for others too!

Viewing 2 replies - 1 through 2 (of 2 total)