Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards!

Tim Kerremans

Forum Replies Created

Viewing 15 posts - 16 through 30 (of 61 total)
  • Author
    Posts
  • in reply to: Only apply function on certain page #138286
    Tim Kerremans
    Participant

    They are not helping me.
    They are telling me I need to reach out to you as this is a page that is created by your plugin and therefore I need the correct filter to check for this page

    Tim Kerremans
    Participant

    Hi,

    I gave them the full explanation, they suggested to debug further so I logged the errors in debug.log file and when uploading I receive two logs in that file, I attached the log to this message.

    Also this is what another guy from WP form told me:
    You might be able to use data returned by get_current_screen() to check if the correct page is being vistited. Once that check is passed, you can perform your other checks such as is_user_wcmp_vendor(). Note that anything specific to is_user_wcmp_vendor() is out of scope here on WPSE as third-party plugins are not covered. Also, your code is going to cause problems because if the first condition is not met, $file is never returned. Filters should always return a value.

    in reply to: Only apply function on certain page #138268
    Tim Kerremans
    Participant

    Hi,

    I forgot to return $args in the function I shared so I have added it to below code but it still is not working.. The files are not placed in a seperate subfolder, all files go to the same location while CSV and PDF files should go to different folder.

    add_filter( ‘as3cf_object_meta’, array( $this, ‘object_meta’ ), 10, 4 );

    function object_meta( $args, $post_id, $image_size, $copy ) {
    global $WCMp;
    $current_endpoint_key = $WCMp->endpoints->get_current_endpoint();
    // retrive the actual endpoint name in case admn changes that from settings
    $current_endpoint = get_wcmp_vendor_settings( ‘wcmp_’ . str_replace( ‘-‘, ‘_’, $current_endpoint_key ) . ‘_endpoint’, ‘vendor’, ‘general’, $current_endpoint_key );
    // retrive edit-product endpoint name in case admn changes that from settings
    $edit_product_endpoint = get_wcmp_vendor_settings( ‘wcmp_edit_product_endpoint’, ‘vendor’, ‘general’, ‘edit-product’ );
    //Return if not edit product endpoint
    if ( $current_endpoint == $edit_product_endpoint ) {

    $extension = pathinfo( $args[‘Key’], PATHINFO_EXTENSION );

    // Example places (potentially large) movie files in a different bucket than configured.
    // Also changes path prefix to match that used in CDN behavior’s “Path Prefix” for this second origin.

    if ( in_array( $extension, array( ‘pdf’, ‘csv’ ) ) ) {
    // Change bucket.
    $args[‘Bucket’] = ‘media.holymowly.com’;

    // Change key (don’t do this for images, thumbnails will not get new prefix and will not be usable).
    $filename = pathinfo( $args[‘Key’], PATHINFO_FILENAME ) . ‘.’ . $extension;
    $args[‘Key’] = ‘files/’ . $filename;
    }

    // Example sets “Content-Disposition” header to “attachment” so that browsers download rather than play audio files.
    /*
    if ( in_array( $extension, array( ‘mp3’, ‘wav’ ) ) ) {
    // Note, S3 format trims “-” from header names.
    $args[‘ContentDisposition’] = ‘attachment’;
    }*/

    return $args;

    }
    }

    in reply to: Only apply function on certain page #138233
    Tim Kerremans
    Participant

    add_filter( ‘as3cf_object_meta’, array( $this, ‘object_meta’ ), 10, 4 );

    function object_meta( $args, $post_id, $image_size, $copy ) {
    $extension = pathinfo( $args[‘Key’], PATHINFO_EXTENSION );

    // Example places (potentially large) movie files in a different bucket than configured.
    // Also changes path prefix to match that used in CDN behavior’s “Path Prefix” for this second origin.

    if ( in_array( $extension, array( ‘pdf’, ‘csv’ ) ) ) {
    // Change bucket.
    $args[‘Bucket’] = ‘media.holymowly.com’;

    // Change key (don’t do this for images, thumbnails will not get new prefix and will not be usable).
    $filename = pathinfo( $args[‘Key’], PATHINFO_FILENAME ) . ‘.’ . $extension;
    $args[‘Key’] = ‘files/’ . $filename;
    }

    // Example sets “Content-Disposition” header to “attachment” so that browsers download rather than play audio files.
    /*
    if ( in_array( $extension, array( ‘mp3’, ‘wav’ ) ) ) {
    // Note, S3 format trims “-” from header names.
    $args[‘ContentDisposition’] = ‘attachment’;
    }*/

    Tim Kerremans
    Participant

    Hi,

    They recommended to try debugging REQUEST_URI so I logged this in the errorlog and got the following log:
    [24-Jun-2022 08:28:02 UTC] PHP Warning: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ (this will throw an Error in a future version of PHP) in /home/customer/www/staging5.holymowly.com/public_html/wp-content/themes/rehub-theme-child/functions.php on line 408

    And they also also recommended the following: would it be better to use applicable WP is_* function for checking the current page (ie /edit-post/) ?
    -> I already tried getting the page based on template / ID without success.

    Hope this gives you some additional information to make this work.

    in reply to: Only apply function on certain page #138210
    Tim Kerremans
    Participant

    Hi,

    Thanks for this, how would this merge with the code I provided? Just tried combining them but now function seems to be ignored, all content is now uploading to the same bucket

    in reply to: Get post id while uploading image #138185
    Tim Kerremans
    Participant

    Hi,

    Not sure about the default flow but in my case the the product is created and saved as draft once vendors are on edit-product page. I can see this as the products can be found in products -> drafts. There I can see in the URL that they do have a post ID assigned to them. Therefore I thought that it should be possible to grab the post id on the edit-product page.

    If not, how should I use the hook? Add to the existing function or create a seperate function?

    in reply to: Display message if default title is assigned #138173
    Tim Kerremans
    Participant

    Yes, ticket is resolved 🙂

    in reply to: Assign default commission value #138127
    Tim Kerremans
    Participant

    This issue has been resolved in the meantime so ticket can be closed 🙂

    Tim Kerremans
    Participant

    Hi,

    Have posted this question on multiple forums in the meantime without any success. How can I do all these things on a WP hook?
    I’m definitely willing to reach out to WP support but not sure how to create this hook as I don’t have much experience with PHP

    in reply to: Display message if default title is assigned #138108
    Tim Kerremans
    Participant
    This reply has been marked as private.
    in reply to: Get post id while uploading image #138098
    Tim Kerremans
    Participant

    It would be even better if the title of the product image is updated to the product ID when the product is submitted on the edit-product page. Maybe this is also easier to achieve?

    So when vendor cliks on SUBMIT on edit product page -> Image title has to be change to Product ID

    in reply to: Display message if default title is assigned #138097
    Tim Kerremans
    Participant

    This works perfectly, thanks!

    in reply to: Get post id while uploading image #138095
    Tim Kerremans
    Participant

    Hi,

    Like I said it is working on WP Admin, but it is not working on the edit-product page from Advanced Frontend Manager plugin. (This is where the vendors upload images)

    I think that is clear enough for you to test it, or do you need a video?

    in reply to: Display message if default title is assigned #138043
    Tim Kerremans
    Participant

    It seems like you didn’t understand what I’m trying to do.

    This is the flow:
    Step 1) Product gets created -> default title ‘Product’ is assigned
    Step 2) Vendor edits product but forgets to edit the title and attach an image
    Step 3) Vendor tries to submit the product
    Step 4) Vendor gets message saying that he must attach image and change the default title before he can publish the product

    The code i shared in this forum message was just a code I copy-pasted from another forum topic of this website for you to have a starting point. This code checks if title and image is set to the product.

    What I’m asking: I need to check if the title equals ‘Product’, if so, the vendor must receive this error message as he cannot submit product with default title. If not, the vendor can publish the product as usual

Viewing 15 posts - 16 through 30 (of 61 total)