getting added behind the URL of a href attribute in an <a> tag

In a helper plugin for WooCommerce for WordPress, I’m trying to create a custom message to be sent to a buyer.

I don’t know why in all the emails that are sent out, %0d%0a is getting added behind the URL in the href attribute. I have tried several different combinations and nothing is working.

Read More

This is what I’m trying to do:

echo "<a href='$cl'> Please click here to redeem the coupon</a>";

But because %0d%0a is being added at the back of it the URL doesn’t work properly for coupon codes.

This is what the URL looks like afterwards:

https://www.example.com/product-1/?couponCode=TDXGUA9G&utm_source=test&utm_medium=testt&utm_campaign=test&aff_code=TSJU89XYZ%0d%0a

The only thing that doesn’t add %0d%0a is this:

 echo $cl;

But I want to be able to use the <a> tag so that the buyer doesn’t have to click on a long URL link.

Related posts

3 comments

  1. Try this

    echo "<a href='" . $cl . "'> Please click here to redeem the coupon</a>";
    

    If you still have the issue, check how $cl was created.

  2. I really appreciate all the responses. But I just want to post the code that finally worked for me after 7 hours of work. I understand that it looks silly but this is the best I could do for now. Here’s what worked for me:

        ?>
        <a href='<?php echo trim($cl); ?>'> <span color="#557da1">Click here to take <?php echo ' '.$_product_name.'</span></a>';
    
  3. I just encountered the same issue, but I’m using ASP.NET. All I did was delete the single quote and type it again. Now it works.

    <asp:HyperLink ... NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Name") %>' />
    

    There were possibly some extra invisible characters which needed to be deleted.

Comments are closed.