Support » Plugin: Relevanssi - A Better Search » No indexing with Simple WordPress Membership and Partial Protection

  • Resolved ilafarad

    (@ilafarad)


    Hello,

    I use the plugins:
    Simple WordPress Membership, version 3.9.7
    SWPM Partial Protection, Version 1.3
    Relevanssi, version 4.7.2.1

    The protected content is not indexed and cannot be found in the “relevanssi” database table.

    [swpm_protected]
    protected content
    [/ swpm_protected]

    I tried to solve the problem as described here:
    https://wordpress.org/support/topic/search-not-working-with-simple-membership-plugin-and-partial-protection-add-on/

    Try this:

    add_filter(‘pre_option_relevanssi_disable_shortcodes’, ‘rlv_swpm_protected’);
    function rlv_swpm_protected($shortcodes) {
    $shortcodes = “swpm_protected,” . $shortcodes;
    return $shortcodes;
    }

    Unfortunately without success. Thank you for your help!

    The page I need help with: [log in to see the link]

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

    (@msaari)

    If you try this indexing debugging trick on a post with protected content, what does it print out?

    Hello Mikko,

    many thanks for the answer!

    Custom fields to index: _wpml_media_featured, _wpml_media_duplicate, _edit_lock, _edit_last, _wpmf_gallery_custom_image_link, _gallery_link_target, _oembed_3035bf2c0fdef9669c3aef96a5b00c64, _oembed_a225fb1f814ab86e8db801353970f406, _oembed_time_a225fb1f814ab86e8db801353970f406, _oembed_f36ed7376b67dd5c1965a8547b2a4081, _wp_page_template Key: _wpml_media_featured - value: 0 Key: _wpml_media_featured - value: 0 Key: _wpml_media_featured - value: 0 Key: _wpml_media_duplicate - value: 0 Key: _wpml_media_duplicate - value: 0 Key: _wpml_media_duplicate - value: 0 Key: _edit_lock - value: 1589986087:1 Key: _edit_last - value: 1 Key: _wpmf_gallery_custom_image_link - value: http://www.duevelsdorf.de Key: _gallery_link_target - value: Key: _oembed_3035bf2c0fdef9669c3aef96a5b00c64 - value: {{unknown}} Key: _oembed_a225fb1f814ab86e8db801353970f406 - value: <blockquote class="wp-embedded-content" data-secret="OE0n7a5X7h"><a href="https://knowthecode.io/docx/wordpress/templatepath">TEMPLATEPATH</a></blockquote><iframe title="“TEMPLATEPATH” — Know the Code" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" src="https://knowthecode.io/docx/wordpress/templatepath/embed#?secret=OE0n7a5X7h" data-secret="OE0n7a5X7h" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe> Key: _oembed_time_a225fb1f814ab86e8db801353970f406 - value: 1586272681 Key: _oembed_f36ed7376b67dd5c1965a8547b2a4081 - value: {{unknown}} Key: _wp_page_template - value: default Indexing post title. Title, tokenized: aedes Indexing post content. Post content after relevanssi_post_content: [swpm_protected] <div style="float: left; margin-bottom: 3em;">AEDES Hubstapler Sonnenstr. 24 39010 Andrian (BZ) Italien Tel. +39-0471-510443 Fax +39-0471-510403 <a href="mailto:info@aedes.bz">info@aedes.bz</a> <a href="http://www.aedes.bz">www.www.aedes.bz</a></div> <div style="float: right; margin-bottom: 3em;"> <table class="lieferanten-legende"> <tbody> <tr> <td class="logo" colspan="2"><img class="alignnone size-full wp-image-482" src="https://ilafa.eu/wp-content/uploads/logo-Aedes.jpg" alt="Logo Aedes" width="" height="" /></td> </tr> <tr> <td class="sterne" colspan="2"><a href="/erlaeuterung-zu-lieferantenpartnern/"><img class="alignnone size-full wp-image-488" src="https://ilafa.eu/wp-content/uploads/sterne-10.jpg" alt="" width="106" height="31" /></a></td> </tr> <tr> <td><a href="/erlaeuterung-zu-lieferantenpartnern/"><img class="alignnone size-full wp-image-486" src="https://ilafa.eu/wp-content/uploads/bei-ILAFA-bestellen.jpg" alt="" width="" height="" /></a></td> <td></td> </tr> </tbody> </table> </div> [LieferantNavi lieferant="Aedes"] <h3 id="Portfolio">Portfolio</h3> Mulchgeräte, Rotormulcher, Scherenmulcher, Schlegelmulcher [Downloads lieferant="Aedes"] [/swpm_protected] [swpm_protected visible_to="not_logged_in_users_only"] Sie sind nicht angemeldet. Zur <a href="/">Anmeldung</a>. [/swpm_protected] Content, tokenized: Final indexing query: INSERT IGNORE INTO il_relevanssi (doc, term, term_reverse, content, title, comment, tag, link, author, category, excerpt, taxonomy, customfield, type, taxonomy_detail, customfield_detail, mysqlcolumn) VALUES (640, '1589986087', REVERSE('1589986087'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 'post', '', '', 0), (640, 'www', REVERSE('www'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 'post', '', '', 0), (640, 'duevelsdorf', REVERSE('duevelsdorf'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 'post', '', '', 0), (640, 'unknown', REVERSE('unknown'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 'post', '', '', 0), (640, 'templatepath', REVERSE('templatepath'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 'post', '', '', 0), (640, '1586272681', REVERSE('1586272681'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 'post', '', '', 0), (640, 'default', REVERSE('default'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 'post', '', '', 0), (640, 'aedes', REVERSE('aedes'), 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'post', '', '', 0)

    Plugin Author Mikko Saari

    (@msaari)

    For starters, set the “Custom fields to index” to “Visible”, there’s a ton of garbage in your index from the invisible custom fields.

    The problem here is that when you disable a shortcode like you do, Relevanssi replaces the shortcode with one that returns an empty string. In your case, that’s not what you want.

    If you set Relevanssi to not expand shortcodes when indexing, does that get you the results you want?

    Hello Mikko,

    many thanks for the answer!

    I have created a simple page.
    Content:
    Test: public content.
    [swpm_protected]
    Test: private content.
    [/swpm_protected]

    Settings:
    Custom fields to index: Visible
    Expand shortcodes: No

    In the search, the result does not matter whether I am logged in or logged out:
    “public” is found
    “private” is not found

    “private” should also be found for logged in users.

    In the database table relevanssi is
    “public” entered
    “private” is missing

    indexing debugging trick:
    Custom fields to index: Indexing post title. Title, tokenized: test Indexing post content. Post content after relevanssi_post_content: Test: public content. [swpm_protected] Test: privat content. [/swpm_protected] Content, tokenized: test public Final indexing query: INSERT IGNORE INTO il_relevanssi (doc, term, term_reverse, content, title, comment, tag, link, author, category, excerpt, taxonomy, customfield, type, taxonomy_detail, customfield_detail, mysqlcolumn) VALUES (1499, ‘test’, REVERSE(‘test’), 1, 1, 0
    , 0, 0, 0, 0, 0, 0, 0, ‘post’, ”, ”, 0), (1499, ‘public’, REVERSE(‘public’), 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘post’, ”, ”, 0)

    Thank you for your help!

    Plugin Author Mikko Saari

    (@msaari)

    The problem that the “expand shortcodes” setting is off. When it’s off, the filter hook to disable the shortcode doesn’t run. Switch that setting on and rebuild the index, and it should work.

    In any case, there’s no way to set this up so that “private” is only found for logged-in users. Relevanssi will only see the words “public” and “private” appear in the post, and knows nothing more. Relevanssi post controls are based on post-level settings, so Relevanssi can handle posts that are private and posts that are public – but posts with private and public parts is something Relevanssi can’t do.

    So if you have Relevanssi index the private content, users who are not logged in can find the posts based on the private content. They won’t be able to see the private content, though, and it’s probably a good idea to keep the protection shortcode active in excerpts, so that the private content doesn’t appear in excerpts (it might be possible to adjust that so that it works based on whether the user is logged in or not, ie. logged in users will see private content in excerpts and logged out users will not).

    Hello Mikko,

    I changed it, but it doesn’t work

    Expand shortcodes when indexing: yes
    rebuild the index

    The result is the same:
    “privat” is not found

    Plugin Author Mikko Saari

    (@msaari)

    Where have you placed the filter function? Are you sure it’s running? If it’s running and it still doesn’t work, I don’t know what’s up with it and can’t really help you further with this.

    Hallo Mikko,

    die Funktion habe ich ans Ende der Datei functions.php in meinem twentysixteen-child gesetz.

    Alle anderen Funktionen hier funktionieren.

    Hello Mikko,

    I have the function at the end of the functions.php file in my twentysixteen-child.

    All other functions work here.

    Plugin Author Mikko Saari

    (@msaari)

    You can try this:

    add_filter( 'relevanssi_post_content', 'rlv_remove_swpm_protected' );
    function rlv_remove_swpm_protected( $content ) {
        $content = preg_replace( '/\[\/?swpm_protected.*?\]/im', ' ', $content );
        return $content;
    }

    That may work.

    • This reply was modified 1 month, 2 weeks ago by Mikko Saari.

    Hello Mikko,

    I changed it, but it doesn’t work

    “privat” is not indexed in il_relevanssi (database table)

    Plugin Author Mikko Saari

    (@msaari)

    There was an extra space in the code, please try again (and remember to reindex after changing the code). If that doesn’t help, then I’m sorry, but that’s all the help I can offer now, any further assistance would require me to have access to your site so I could take a look at what’s actually happening.

    Hello Mikko,

    it works! 🙂

    (I always created the index again)

    Thank you for your help!

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.