• Resolved justinkerbo

    (@justinkerbo)


    I am using wp_referral_code_after_refer_submitted to email the site admin so they have a link to the referree to reward them. For some reason when I concat $referrer_user_id to the URL, no matter what I try it returns the ID with “3D in front of it.

    For example, if the user ID is 6. it will return 3D6

    I’m not sure where the “3D” is coming from.

    If I remove the URL and only call $referrer_user_id for the email message then it will display the ID correctly without the 3D in front of it.

    add_action( ‘wp_referral_code_after_refer_submitted’, function ($new_user_id, $referrer_user_id){
    $url = “[domain]”.$referrer_user_id;
    wp_mail(“[myemail]”, “A member has successfully invited a new user”, $url);

    }, 10, 2 );

    The code above will display https://holistic.devbo.digital/wp-admin/user-edit.php?user_id=3D35

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter justinkerbo

    (@justinkerbo)

    Surprisingly I used Chat GPT to diagnose the issue. Even though we didn’t find what was causing it. We found that if I use the mail() function, the URL won’t have the ‘3D’ at the end of it.

    My next issue is the plugin is only recording 1 referral per user. Their first referral is recorded, but after 1 person signs up on their referral link it’s basically a dud and won’t trigger anything. Chat GPT doesn’t seem to have an answer for me for this one.

    Plugin Author shalior

    (@shalior)

    Hey Justin, %3D is urlencoded equivalent of `=. My guess is somewhere in generating the URL you’re using an encoding of some sort.

    try to generate the URL with:

    $user_link = admin_url( 'user-edit.php?user_id=' . $referrer_user_id);

    using the native mail function in WordPress is considered to be bad practice. you’re gonna face problems using it.

    also maybe setting mail’s content to text/html solves your issue.

    • This reply was modified 1 year, 11 months ago by shalior.
    Plugin Author shalior

    (@shalior)

    My next issue is the plugin is only recording 1 referral per user. Their first referral is recorded, but after 1 person signs up on their referral link it’s basically a dud and won’t trigger anything. Chat GPT doesn’t seem to have an answer for me for this one.

    The plugin removes referral cookies after a successful registration. try to test the process with incognito mode. make sure you have a link with ?ref=[user_ref_code]

    Plugin Author shalior

    (@shalior)

    I may add this feature to plugin’s core, Hopefully in the next update.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘$referrer_user_id is returning incorrectly’ is closed to new replies.