PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Creating a site when updating an existing user

  1. I'm developing a site which has a multi step procedure for creating a site on a multisite install. This involves having the user first create a user account, then create their site at a later date.

    When using the Registration Add-On to update the user account, a network site is not created, despite having the option selected under the Registration Add-On's Network Options.

    A network site is created when the form is set up to create a new user.

    I'm using WP 3.5.1, Gravity Forms 1.6.12 and Gravity Forms User Registration Add-On 1.5.beta1

    I'm using the following code to pre-populate the user's first & last names:

    add_filter('gform_field_value_user_firstname', create_function("", '$value = populate_usermeta(\'first_name\'); return $value;' ));
    
    add_filter('gform_field_value_user_lastname', create_function("", '$value = populate_usermeta(\'last_name\'); return $value;' ));
    
    function populate_usermeta($meta_key){
        global $current_user;
        return $current_user->__get($meta_key);
    }

    I'm using this to change pre-populated fields to readonly:

    <script type="text/javascript">
            jQuery(document).ready(function(){
                jQuery("li.gf_readonly textarea").attr("readonly","readonly");
                jQuery(".gform_wrapper .readonly input").attr('readonly','readonly');
            });
        </script>

    Any ideas?

    Thanks heaps,
    Cam

    Posted 11 years ago on Tuesday February 5, 2013 | Permalink
  2. I'll bring this to the attention of the development team for their feedback. Thank you for the information and sorry for the trouble.

    Posted 11 years ago on Tuesday February 5, 2013 | Permalink
  3. I heard back from one of the developers today:

    The User Registration Add-On only creates sites when the form is submitted. It is not designed to create the site when the user is updated. However, what you can do is use a WordPress hook that is fired when a user is updated and then call the GFUser::create_new_multisite() function.

    Posted 11 years ago on Thursday February 7, 2013 | Permalink
  4. Hi Chris,

    Thanks for that.

    Do you have / know of any documentation for doing this?

    Thanks heaps

    Posted 11 years ago on Thursday February 7, 2013 | Permalink
  5. I don't. I did not look into WordPress to see what the hook name might be.

    Posted 11 years ago on Friday February 8, 2013 | Permalink
  6. Hi Chris,

    It looks like the best way would be to use the gform_after_submission hook, specifying the form used to update the user account, then use that to use the create_new_multisite function in the User Registration Add-On plugin. That would look something like this:

    function create_multisite_site() {
      create_new_multisite($user_id, $config, $entry, $password);
    }
    add_action("gform_after_submission_5", "create_multisite_site", 10, 2);

    I've searched the docs for how to use the create_new_multisite function, but info is very lite. Are any of your devs able to provide any details regarding what data / variables I need to be using with create_new_multisite() ?

    Posted 11 years ago on Sunday February 10, 2013 | Permalink
  7. Let me forward this to the development team and see if they have any feedback.

    Posted 11 years ago on Sunday February 10, 2013 | Permalink
  8. I'm interested to know a solution for this as well. I'd appreciate the full code / instructions for implementation.

    Thanks

    Posted 11 years ago on Monday February 11, 2013 | Permalink
  9. I'll post a solution here when I hear back from the development team.

    Posted 11 years ago on Monday February 11, 2013 | Permalink
  10. I just tested User Registration beta v1.5.11 and this appears to be working fine. Logged in users can fill out a form to create a new site. Works nicely :)

    Posted 11 years ago on Monday February 11, 2013 | Permalink
  11. Hello Cam,
    I am working on coming up with a code snippet for you, but I am now not sure when the site is supposed to be created. Following are a few options I see.
    1- An administrator updates the entry via the entry detail page
    2- An administrator or user updates the user profile from WP's user profile page
    3- User updates his information via a Gravity Form associated with a User Registration update feed.

    Let me know which you are looking for and I will come up with something for you.

    Posted 11 years ago on Monday February 11, 2013 | Permalink
  12. Hi Alex,

    I'm using option 3, where a user is updating his information via a Gravity Form associated with a User Registration update feed.

    This is for a professional membership site, where users (with a WP Subscriber account) must first apply for full membership and supply supporting documentation. Once Admin has approved their application they have access to a Gravity Form associated with a User Registration update feed where they can enter the details for their site name, url and agree with the T&Cs. Their name, username and email address are pre-populated readonly fields.

    Thanks so much for your help!

    Posted 11 years ago on Tuesday February 12, 2013 | Permalink
  13. I think the following will do the job. (Assumes that form ID 5 is your update profile form)

    function create_multisite_site($entry, $form) {
    
        $user_id = get_current_user_id();
        $config = GFUser::get_active_config($form, $entry);
    
        $blog_id = GFUser::create_new_multisite($user_id, $config, $entry, "");
    
    }
    add_action("gform_after_submission_5", "create_multisite_site", 10, 2);
    Posted 11 years ago on Wednesday February 13, 2013 | Permalink
  14. Hi Alex,

    That function works perfectly. Thank you so much for your help!

    Posted 11 years ago on Friday February 15, 2013 | Permalink
  15. Thanks for the update Cam. I will let Alex know this worked.

    Posted 11 years ago on Friday February 15, 2013 | Permalink

This topic has been resolved and has been closed to new replies.