• Hey again Mikko,

    One more thing I just realized: Relevanassi doesn’t seem to be indexing content in private posts using the Role-Scoper plugin. Since 50% or so of my posts are only group-access, this pretty much means that only half the blog can be searched…

    I reckon this could be a dealbreaker for quite a few users, as Role-Scoper has become quite the popular plugin lately… :/

    Any tips to get it working would be greatly appreciated!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Well, this is the first time I hear of Role-Scoper… but I’ll put this on my todo list. I suppose it’s possible to index everything and only show hits if the visitor has access to them.

    Thread Starter kuprosa

    (@metal450)

    Excellent; since I’ve pretty much got Relevanssi all integrated into the site, I’ll just hang tight for this one and then activate the new version whenever available.

    After having a look at yours and the RS source, I suspect it may actually be quite simple. Once the indexing query in relevanssi_build_index() is updated to include “private” posts as well as “published,” Role Scoper provides the following function which could be used as you suggest, to limit what actual results Relevanssi returns: awp_user_can( ‘read_post’, $post_id, $user_id ). And then if Role-Scoper is not detected, you’d of course just filter out all posts without “publish” status, leaving the behavior pretty much as it’s currently written.

    I’d do it myself, but since it’d just get overwritten the next time you update rather hang tight until then ??

    Plugin Author Mikko Saari

    (@msaari)

    Luckily I’m on vacation next week, so I can do something about this pretty soon.

    Thread Starter kuprosa

    (@metal450)

    Sweet ?? I’ve been spending most of the weekend updating all of my plugins as well… (submitted under a different username, though) ??

    Plugin Author Mikko Saari

    (@msaari)

    Figuring this one out was surprisingly difficult – the whole thing is weakly documented (the key function, current_user_can(), is not documented at all in the Codex). I’ve got the basics now, and I’m moving on to integrating Role-Scoper.

    Thread Starter kuprosa

    (@metal450)

    Yeah, the code-wise documentation for RS is pretty bad…but it is a spectacularly versatile plugin. 60,000 downloads can’t lie! ??

    Thread Starter kuprosa

    (@metal450)

    So, the other 3 features look great – this one doesn’t quite work yet though. The problem is this:

    When performing a search as an anonymous (not-logged-in) user for a term that does exist in non-private posts, I get results like “showing 0 of 6 results.”

    I tried dumping the $hits array returned by relevanssi_search on line 423 and confirmed that it does indeed contain the correct results. However, it’s indexed like this:

    Array
    (
    [16] => 7797
    [17] => 95
    [18] => 111
    [19] => 196
    [20] => 240
    [21] => 79
    )

    Then just below on line 437, you loop from $wpSearch_low to $wpSearch_high. Here, those values were 0 and 5. Thus, because the loop starts with a test that skips if (!isset($hits[intval($i)])), all of the results are skipped – since their indices are 16-21, fully outside the 0-5 range.

    Plugin Author Mikko Saari

    (@msaari)

    I think I figured this one out – the array index is increased even if the post is deemed unappropriate for the user to see.

    Find this bit in the code (around line 860):

    if ($post_ok) $hits[intval($i)] = $doc;
    			$i++;

    and move the $i++ inside the if clause (I think $hits[intval($i++)] should work). Let me know if that works.

    This was a pretty hard one test, as I found Role-Scoper fairly difficult and confusing to config.

    I didn’t read RS docs, I just used what you told me – that was the easy bit, but the basic WordPress functions were the ones with bad documentation and lots of difficulties.

    Thread Starter kuprosa

    (@metal450)

    Looks like that did it!

    Once the “official” 2.0.2 is available I’ll run it through some more rigorous testing, but at the moment it looks 100%. I’ll send u a link to the finished product once it’s all wired in ??

    Plugin Author Mikko Saari

    (@msaari)

    Good, I just committed 2.0.2.

    Thread Starter kuprosa

    (@metal450)

    Alrighty – we’re good here, but there’s still a bug with orderBy, hehe ?? I’ll address it back on the other thread…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: Relevanssi] Role-Scoper "conflict"’ is closed to new replies.