Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get member ID right after registration

  • using my plugin i am trying to attach a function to the registration form. This function needs the member id in order to run. i am looking for a hook that runs right after the member was created in the registration process , get the member id and run my function using that.

    any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of dcavins
    dcavins
    Participant

    @dcavins

    Since registration involves a redirect to another page, why not attach your function to `init`, which is fired when a WP page is starting to load?

    `function get_member_ID() {
    global $current_user;
    get_currentuserinfo();
    $ID = $current_user->ID;
    // Do stuff with user ID.
    }
    add_action(‘init’, ‘get_member_ID’);`

    Or you could do something when the user logs in:

    `function get_member_ID_login() {
    global $user;
    $user->ID;
    // Do stuff with user ID.
    }
    add_action(‘wp_login’, ‘get_member_ID_login’, 100, 3);`

    There are some hooks in the registration process, too, I’m just not familiar with them.

    Thank you Dcavins,
    im not sure i can use the suggestions.well, at least not the second option since i need the function to run right after the registration using information that the user entered.
    this is what i am trying to do. the purpose of the plugin is to let members add their location and also to create a search form that let users search members near address entered within a certain radius. There is a already a “location” tab for the user to enter the address and it works fine. Now i am trying to connect the location to the registration form to make it mandatory (if admins choose to). the things is that in order to save the location in the database i need the member’s id.
    and so, i am trying to add the location fields into the registration form and make it mandatory and once the user fill up the form it will run the registration process and right after will grad the ID that was created , grad the info from the address fields and run the function i need.
    so i guess i need some kind of “after_member_created” hook.

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

You must be logged in to reply to this topic.