Redirect with download button

Posted by: ANDERSON CANTILLO

20th October 2020, 10:19 pm

ANDERSON CANTILLO

@ANDEROCK

20 Oct 2020
10:19 pm

Instead of displaying the message of limit reached. Redirect to the other page with the product download button. It's possible?

  • Richard Webster

    @rwebster

    20 Oct 2020
    10:33 pm

    Hi Anderson, I replied to your email about this but didn't hear back. Here's my reply:

    Hi mate, the default behaviour is the user gets redirected to the product page and the download limit reached message shows up on there.

    What is it that you want to do differently?

  • ANDERSON CANTILLO

    @ANDEROCK

    20 Oct 2020
    10:53 pm

    When you reach the download limit the button will redirect to another page where you can buy the membership

  • Richard Webster

    @rwebster

    20 Oct 2020
    10:55 pm

    Gotcha 👍

    Leave it with me. There isn't a super easy way to do that right not, but I might be able to write a custom function you can add to your site.

  • ANDERSON CANTILLO

    @ANDEROCK

    20 Oct 2020
    11:01 pm

    Yes. Explain to me how you can change some code or how you can help me?

  • ANDERSON CANTILLO

    @ANDEROCK

    21 Oct 2020
    12:15 am

    Richard. I hope you can help me as soon as possible.

  • Richard Webster

    @rwebster

    21 Oct 2020
    7:55 am

    I'll be looking at it today for you 🙂

  • ANDERSON CANTILLO

    @ANDEROCK

    21 Oct 2020
    8:01 am

    Richard. I appreciate. You can send me to my mail. IF you find any way to do it from the plugin files?

    Last modified: 21st October 2020, 8:02 am by ANDERSON CANTILLO

  • Richard Webster

    @rwebster

    21 Oct 2020
    10:28 am

    Hi Anderson,

    It's easier to post here because of the formatting.

    Here's the code you need. Install the plugin called Code Snippets, create a new snippet and paste the code in. Make sure you change the number for $page_id from 80 to the ID of the page you want to redirect users to.

    add_action('template_redirect', 'free_downloads_custom_limit_reached_redirect', 99);
    function free_downloads_custom_limit_reached_redirect()
    {
        $somdn_errors = $_REQUEST['somdn_errors'] ?? '';
        if (empty($somdn_errors)) {
            return;
        }
    
        $limit_reached = $somdn_errors[0]['download_limit_reached'] ?? '';
        if (empty($limit_reached)) {
            return;
        }
    
        // ID number of the page to redirect the user to.
        $page_id = 80;// CHANGE THIS
    
        $page_url = get_the_permalink($page_id);
        $redirect_url = esc_url($page_url);
    
        wp_safe_redirect($redirect_url);
        exit;
    }

This topic is closed to new replies.

Looking for Square One Media? Check this post