Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

When a user registers I'd like to add their member_id to a different table

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Tweaks › When a user registers I'd like to add their member_id to a different table

Tagged: customization, Tweaks, wp membership

  • This topic has 3 replies, 2 voices, and was last updated 6 years, 8 months ago by nullsignature.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • August 31, 2018 at 9:51 pm #15055
    nullsignature
    Member

    I’ve built a separate MySQL table (user history, in the same database as wordpress) for a specific tool and would like to insert the eMember ID into it whenever someone registers (in addition to the normal database handling for eMember). I assume eMember_registration_utils.php is the best page to do this. What is the best function/line to insert this on? And the best way to get the member_id of the user that just registered? Basically, I just want to add something like this this:

    $wpdb->insert(‘user_history’, array(‘userid’ => $memberid>);

    Where

    user_history is my table

    userid is the name of the column

    $memberid is the ID of the newly registered user under eMember

    September 1, 2018 at 5:56 am #78454
    admin
    Keymaster

    The best option is to use our registration complete hook. That way you are not modifying the core plugin files.

    Here is the action hook:

    eMember_registration_complete

    Below is an example snippet of code that shows how to use this hook:

    function handle_registration_complete_event($member_data, $custom_fields)
    {
    //The following line will print all the member details that got passed to this function
    //You can use this data to insert it to your table.
    print_r($member_data);

    }
    add_action('eMember_registration_complete','handle_registration_complete_event',10,2);

    September 3, 2018 at 2:20 pm #78455
    nullsignature
    Member

    Thanks! I’ll give this a shot.

    September 3, 2018 at 2:55 pm #78456
    nullsignature
    Member

    Edit: figured it out. $member_data is an array that doesn’t need to be passed by add_action. Here’s my code for any future searchers. This inserts the newly registered user’s ID into a table called user_question_history.

    function handle_eMember_registration_complete_event($member_data)
    {
    global $wpdb;
    $wpdb->insert('user_question_history', array('user_id' => $member_data['member_id']));
    }
    add_action('eMember_registration_complete','handle_eMember_registration_complete_event');

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ