Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Support: Creating & Extending

Existing and new plugins/components and themes.

How to make 10 digit ID for each new member, and echo it out on members info page (8 posts)

Started 5 months, 2 weeks ago by: seointexas

  • Profile picture of seointexas seointexas said 5 months, 2 weeks ago:

    I am building a network, and one of the member fields needs to be a unique 10 digit number. I need it to echo out on the members info page with their email, hometown, etc. Any ideas?

  • Profile picture of seointexas seointexas said 5 months, 2 weeks ago:

    Okay, I found rand in php, how do I get it into the registration process so it’s not random after it’s chosen for each member?

  • Profile picture of seointexas seointexas said 5 months, 2 weeks ago:

    Okay, well, thanks anyway!

  • Profile picture of modemlooper modemlooper said 5 months, 2 weeks ago:

    Search BuddyPress register hook, you can add code to the registration process. Possibly add a hidden sign up field that generates your number

  • Profile picture of modemlooper modemlooper said 5 months, 2 weeks ago:

    This code is not tested but it’s an example of adding a field and then getting results.

    function bp_numb_add_reg_field() {
       $rand_numb = //php to generate number here ;
       echo '<input type="hidden" name="user_unique_id" value="'. $rand_numb .'" />';
    }
    add_action( 'bp_before_registration_submit_buttons', 'bp_numb_add_reg_field' );
    
    function bp_numb_get_reg_data() {
       if ( isset( $_POST['user_unique_id'] ) ) {
    
         $numb_value = $_GET['user_unique_id'];
          // do something with the custom data
       }
    }
    add_action( 'bp_complete_signup', 'bp_numb_get_reg_data' );
  • Profile picture of seointexas seointexas said 5 months, 2 weeks ago:

    Thanks! I will work with that.

  • Profile picture of seointexas seointexas said 5 months, 2 weeks ago:

    I think I can use rand(1, 1000000);
    but I don’t know what to do with it after that. I created a custom-fields area in my members-header.php file, where I echo out fields with variables, but I don’t know how to get this function from functions.php to members-header.php.

  • Profile picture of etivite etivite said 5 months, 2 weeks ago:

    use one of the various action hooks within members-header.php template file

    http://etivite.com/api-hooks/buddypress/path/bp-themesbp-defaultmemberssinglemember-header-php/