• Resolved mairag

    (@mairag)


    Not sure if this plugin is still maintained but couldn’t find a way to know when a user registers using a referral link, is there a way to let the Admin know? Otherwise, it’s quite pointless if we have to check every user profile manually…

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author shalior

    (@shalior)

    Hey, Use below snippet.
    make sure Settings > General and the field ‘Email Address’ is filled or it won’t work.
    You’re right, this should be in plugin’s core.


    /**
    * WP Referral Code
    * Send admin notification email when a new user registers using a referral code.
    *
    * @param int $new_user_id ID of newly registered user.
    * @param int $referrer_user_id ID of referring user.
    * @param string $ref_code Referral code used.
    */
    function wrc_notify_admin_on_referral_signup( $new_user_id, $referrer_user_id, $ref_code ) {
    // Get admin email
    $admin_email = get_option('admin_email');

    if (!$admin_email) {
    return; // Exit if no admin email is set
    }

    // Get user data
    $new_user = get_userdata($new_user_id);
    $referrer = get_userdata($referrer_user_id);

    // Email subject
    $subject = 'New User Registration via Referral';

    // Email message
    $message = "Hello Admin,\n\n";
    $message .= "A new user has registered using a referral code:\n\n";
    $message .= "New User: ({$new_user->user_email})\n";
    $message .= "Referred by: ({$referrer->user_email})\n";
    $message .= "Referral Code Used: {$ref_code}\n\n";
    $message .= "This email was sent from " . get_bloginfo('name');

    // Send email to admin
    wp_mail($admin_email, $subject, $message);
    }

    // Hook the function to the referral action
    add_action('wp_referral_code_after_refer_submitted', 'wrc_notify_admin_on_referral_signup', 10, 3);
    Thread Starter mairag

    (@mairag)

    Thank you, I’ll give it a try. As a workaround, I added a panel in the Dashboard with a shortcode you provide to show the users with more referrals to do a quick check.

    Plugin Author shalior

    (@shalior)

    No problem, smart move! Let me know if I should mark this as resolved.

    Thread Starter mairag

    (@mairag)

    Yes, I’ll mark it as solved. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Notifications?’ is closed to new replies.