Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating members outside of theme


  • scott8035
    Participant

    @scott8035

    Hi. I’m writing a webhook that’s intended to create a user and register them in BP. After examining function bp_core_screen_signup() in buddypress/bp-members/screens/register.php, I thought I could just stuff values I receive into the correct $_POST variables and call the function, but it immediately returns after this statement near the top:

    if ( ! bp_is_current_component( 'register' ) || bp_current_action() ) {

    So I have two questions:

    1. Am I going in the right direction by emulating a post and calling bp_core_screen_signup() directly? And if so…
    2. What is the correct/proper/best way to set the current component and action?

    Thank you.

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

  • Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    You can directly create a WordPress user also and it will become BuddyPress member automatically.

    Please check: https://wpengineer.com/2054/create-users-automatically-in-wordpress/

    Thanks


    scott8035
    Participant

    @scott8035

    But I also need to save some xprofile fields programmatically, too. Won’t I eventually have to run bp_core_screen_signup() in order to “fully create” a BP member profile?


    Prashant Singh
    Participant

    @prashantvatsh

    When you will use that above link to create user then it is giving you a user_id in return then you can use it to save profile data like this:

    xprofile_set_field_data('profile_field', $user_id , 'profile_field_value');

    You can write it just after the code where you get user_id in return.

    Also please use hook ‘init’ in place of ‘admin_init’ and check a condition in the function if form is posted.

    Please try this once and let us know if this works for you not.

    Thanks


    scott8035
    Participant

    @scott8035

    bp_core_screen_signup() does several other things besides creating the user and saving xprofile fields…it does validation, optionally creates a user blog, provides several action hooks, etc. Are you saying it’s just not practical to use it?


    Prashant Singh
    Participant

    @prashantvatsh

    I am not saying that it’s not practical to use but if it is restricting you to create user through this then the workaround can be the solution I have suggested and I think it will send a mail to the user to let him/her know that their account is created on the site.

    If you want exactly same functionality like BuddyPress registration then please check this plugin as well https://www.gravityforms.com/add-ons/user-registration/ and this is the link where they notified that it is integrated with BuddyPress https://docs.gravityforms.com/user-registration-add-on/#buddypress-integration

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar