WPSolr logo
Search
Close this search box.

Forum Replies Created

  • support
    Participant

    I’ve enhanced the function a little bit by disabling locked downloads indexing

    
    /*
    * Add WP download manager attachements in WPSOLR indexer
    */
    add_filter( WPSOLR_Events::WPSOLR_FILTER_GET_POST_ATTACHMENTS, 'filter_get_wpdm_post_attachments', 10, 2 );
    function filter_get_wpdm_post_attachments( $attachments, $post_id ) {
    
        if ( 'wpdmpro' != get_post_type( $post_id ) ) {
    
    		return $attachments;
    		
        }
    
    	$wpdm_files = get_post_meta( $post_id, '__wpdm_files', true );
    	$wpdm_locked = wpdm_is_locked( $post_id );
    
        if ( ! empty( $wpdm_files ) && !$wpdm_locked ) {
    
            foreach ( $wpdm_files as $key => $file_name ) {
    
                $download_link = get_permalink( $post_id ).'?wpdmdl='.$post_id."&ind=".$key."&filename=".$file_name;
                array_push( $attachments, [ 'url' => $download_link ] );
    
            }
    
        }
    
        return $attachments;
    }
    
    support
    Participant

    Hi there,

    I found my way by adding a filter in the functions.php file of my theme.
    If anyone is looking to index WP Download Manager Pro downloads with WPSolr, here you go

    
    /*
    * Add WP download manager attachements in WPSolr indexer
    */
    use wpsolr\core\classes\WPSOLR_Events;
    add_filter( WPSOLR_Events::WPSOLR_FILTER_GET_POST_ATTACHMENTS, 'filter_get_wpdm_post_attachments', 10, 2 );
    function filter_get_wpdm_post_attachments( $attachments, $post_id ) {
    
        if ( get_post_type( $post_id ) != 'wpdmpro' ) {
            return $attachments;
        }
    
        $wpdm_files = get_post_meta( $post_id, '__wpdm_files', true );
    
        if ( ! empty( $wpdm_files ) ) {
    
            foreach ( $wpdm_files as $key => $file_name ) {
    
                $download_link = get_permalink( $post_id ).'?wpdmdl='.$post_id."&ind=".$key."&filename=".$file_name;
                array_push( $attachments, [ 'url' => $download_link ] );
    
            }
    
        }
    
        return $attachments;
    }
    
    support
    Participant

    Hi there,
    As explained WP download manager has no relation to ACF file field.

    Best File / Document Management & Digital eCommerce Plugin for WordPress


    The plugin has a file field like here:
    __wpdm_files : a:1:{i:0;s:46:”5e312bd311838c_filename.pdf”;}
    I can programmatically add a URL to the pdf file, but not a File type field as ACF makes use of.
    Please, may it be possible to estimate how WPSOLR might include WP download manager files?

    Thank you.

    Best regards,

    Hendrik

    support
    Participant

    Hi there,

    Does it extract file content if I add the URL to the file in a URL field?
    How may I achieve this by having the URL to the file?

    Thank you.

    Bets regards,

    Hendrik

    support
    Participant

    Hi there,

    Apparently my answer didn’t go through.
    I’ve tried to manually and a direct link to the pdf in the post meta fields, but those files aren’t taken into Elasticsearch.
    The wpdownloads attachement field isn’t a standard file type as the files aren’t managed through the WordPress medias.

    How may I achieve this then ?

    Thank you.

    Best regards,

    Hendrik

    support
    Participant

    Hi there,

    I gave it a try because the “Download” post type is recognized.
    If I search for a word that is included in the “Download” post name, WPSolr find it, unfortunately I can’t search text inside any pdf file linked to this post type.

    Even by checking all fields and taxonomies, when I export my data to Elasticsearch, I don’t see a big difference in index size compared to the difference when I ingest other media files.
    There should be 140 pdf files ingested into the index.

    For information, those files aren’t inside the post description, but uploaded in a dedicated WP download manager field on the post itself. Those files also aren’t displayed through the WordPress media file system.

    If you have any knowledge with this kind of behavior, do you have any hypothesis to resolve this?

    Thank you.

    Best regards,

    Hendrik

    support
    Participant
    3 years, 9 months ago in reply to: Simple Elastic cloud setup #21375

    I’m talking to the support team and yes, the hosting provider might be causing the issue by blocking the call on this port.

    Thank you.

Viewing 7 posts - 1 through 7 (of 7 total)