Skip to:
Content
Pages
Categories
Search
Top
Bottom

Given Activation Key, How would you get the User ID?


  • William
    Participant

    @william_oneb

    With the help of @henrywright, I was able to write code that gets the user activation key. Here’s the code:

    function william_oneb_key() {
          if ( empty( $key ) ) {
          $key = bp_current_action();
         // Do something with the key. Just echo it for now.
          echo "The activation key is ";
          echo $key;
      } 
    }
    add_action( 'bp_after_activate_content', 'william_oneb_key' );

    Now that we’ve got the key, How do we get the user id?

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

  • William
    Participant

    @william_oneb

    Is this even possible?


    shanebp
    Moderator

    @shanebp

    Try using this hook do_action( 'bp_core_activated_user', $user_id, $key, $user );
    from buddypress\bp-members\bp-members-functions.php


    William
    Participant

    @william_oneb

    OK here’s how I’d use the hook @shanebp.

    function william_bp_core_activated_user(  $user_id, $key, $user ) {
    // do something with $user_id
    };
    add_action( 'bp_core_activated_user', 'william_bp_core_activated_user', 10, 3 );

    I’d like to assign the user id to another variable. Something like this:

    $userid = william_bp_core_activated_user();

    The above assignment statement doesn’t work though. Any idea how I’d make it work?


    shanebp
    Moderator

    @shanebp

    You need to acquire a basic understanding of WP hooks and filters; how they work and the difference between them. Then it will be obvious why ‘the above assignment’ doesn’t work.

    The only reason william_bp_core_activated_user() has access to $user_id is because it is passed by the hook.


    William
    Participant

    @william_oneb

    I get it now. Maybe there’s no way I’m gonna achieve what I wanted.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Given Activation Key, How would you get the User ID?’ is closed to new replies.
Skip to toolbar