View Categories

Saving Shared Emails

This guide provides code to save emails shared through the WPGENS RAF (Refer a Friend) plugin. You can add this code to your theme’s functions.php file.

Instructions:

1. Open your theme’s functions.php file. You can do this through the WordPress admin panel under Appearance > Theme Editor, or via FTP.

2. Copy and paste the following code at the end of your functions.php file:

// Save RAF shared emails
function save_raf_shared_emails($type, $data) {
    if ($type === 'email_share') {
        $shared_emails = get_option('raf_shared_emails', array());
        $shared_emails[] = array(
            'email' => $data['email'],
            'name' => $data['name'],
            'user_id' => $data['user'],
            'date' => current_time('mysql')
        );
        update_option('raf_shared_emails', $shared_emails);
    }
}
add_action('new_raf_data', 'save_raf_shared_emails', 10, 2);

// Retrieve saved RAF emails
function get_raf_shared_emails() {
    return get_option('raf_shared_emails', array());
}

// Optional: Add a shortcode to display saved emails
function display_raf_shared_emails_shortcode() {
    $shared_emails = get_raf_shared_emails();
    $output = '<ul>';
    foreach ($shared_emails as $email_data) {
        $output .= '<li>' . esc_html($email_data['email']) . ' - ' . esc_html($email_data['date']) . '</li>';
    }
    $output .= '</ul>';
    return $output;
}
add_shortcode('raf_shared_emails', 'display_raf_shared_emails_shortcode');
  1. Save the functions.php file.

Usage:

  • The code will automatically save shared emails to the WordPress database.
  • To retrieve saved emails in your PHP code, use: $emails = get_raf_shared_emails();
  • To display saved emails on a page or post, use the shortcode: [raf_shared_emails]
What they say

Trusted by 7000+ customers

Our plugins are used by more than 7000 websites across the globe. All of our plugins are rated 5 stars on WordPress.org. Don’t just take our word for it, check what others are saying about WPGens.

I bought and tested the plugin with WooCommerce Subscription and it works like a charm. I had some specific questions to the developer and he responded very fast and helped me. I suggest the plugin!

Refer a Friend PREMIUM
@rinpocse91

If your looking to set up a referral program on your WooCommerce site to boost up your site sale “Refer A Friend for WooCommerce by WPGens” is your plugin to go for. Little blown away with an amazing support provided from (Goran) the plugin working exactly what you want to set up a referral system. Good job guys!

Refer a Friend PREMIUM
@samroon007

We deal with dozens of applications and plugins on a daily basis. Many of them are excellent, but few have truly excellent support. The Refer A Friend plugin is one of them: the response to my questions is always fast, friendly and very helpful.

Refer a Friend PREMIUM
@smartDIYer

This plugin is awesome. It looks good, it’s light weight, has great support – everything you can expect from a paid plugin, only it’s free!!!!

Swifty Bar
@ofirbeigel

Read all testimonials on WordPress Repository.

Get notified when we add new plugins.

We do not publish plugins often, but when we do, it's something awesome. No spam, we promise.

bool(false)