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.

Multisite Creation: 1 input for title and url

  1. I am trying to implement a very easy form for creating a new subsite - 1 input. The 1 input is being used for site address and site title. However, it is sending the input to the site address without the " / " at the beginning, so new sites are being listed as example.comnewsite instead of example.com/newsite . Is there someway I can use the pre submission filter to add that / in before it is sent to the site address function?

    Posted 6 years ago on Friday January 25, 2013 | Permalink
  2. If it is being sent without, and you want to add the slash there, you can use this for your gform_pre_submission_filter:

    [php]
    add_filter("gform_pre_submission_filter", "add_a_slash");
    function add_a_slash($form) {
    
        // add a slash before the information which was captured
        $_POST["input_1"] = "/" . $_POST["input_1"] ;
    
        // return modified form object
        return $form;
    }

    That would add a slash to the beginning of the string which was entered. But without seeing all your code and how you're using this, I can't be sure if this will work or see how it will work for both the site title and site address (slug.) Share more information if you need more help.

    Posted 6 years ago on Sunday January 27, 2013 | Permalink
  3. Hello, thanks for the reply.

    sorry for the typo, it should say 'without'

    I actually tried that, but realized doing that puts the the slash in front of the Site Title too. So I was wondering if there is a action or filter to modfy the entry before the user-registration handles it?

    Posted 6 years ago on Sunday January 27, 2013 | Permalink
  4. I would do this with two fields then. I would have a hidden or admin only field in the form, and take the information from input_1, add the slash, then assign it to input_2. Then use input_1 unmodified for the title, and input_2 for the URL.

    Just change one line above (after you add the hidden field to your form, and if these are your field IDs):

    // assign the value with the slash to another field
    // I used field 2
    $_POST["input_2"] = "/" . $_POST["input_1"] ;
    Posted 6 years ago on Sunday January 27, 2013 | Permalink
  5. That sounds perfect, I'll do that. Do I use the same hook you had above?

    Posted 6 years ago on Sunday January 27, 2013 | Permalink
  6. Everything will be the same except the one line. The hidden field is just there so you have a place to store the modified value. Make sure the input_X numbers are correct.

    Posted 6 years ago on Sunday January 27, 2013 | Permalink
  7. Okay, so I put the code in place, but user registration is throwing an error for the blank field:

    "Please enter a site name."

    I tried to strip validation errors from the whole field but wasn't able to. Is there a way I can bypass this?

    Posted 6 years ago on Sunday January 27, 2013 | Permalink
  8. That field should not be required. Did you mark it as such? It should be admin only and not required. It won't be filled in by the visitor. It's an empty spot for you to store a value after the visitor fills out the form.

    Posted 6 years ago on Monday January 28, 2013 | Permalink
  9. I think it is the User Registration that checks it as 'required' because it is selected in one of the feeds in the back end even though when viewing it in the form editor it is not marked as required. With that said, simply inputting any value passes that check, and then the entry is reformatted with the above function you wrote.

    However, for some reason this stops the site creation process -- nothing happens. The form entry appears with the correct information, but a new site is not created. Any ideas why this is happening?

    Posted 6 years ago on Monday January 28, 2013 | Permalink
  10. Can you share a link to your form online please?

    Posted 6 years ago on Monday January 28, 2013 | Permalink
  11. Can I send it over email?

    Posted 6 years ago on Tuesday January 29, 2013 | Permalink
  12. I tried this, as something different to see what happend, but didn't get a result:

    add_action("gform_site_created", "modify_domain", 10, 2);
    function modify_domain($site_id, $entry) {
    	$title = '/'.$entry["1"];
    	update_blog_option ($site_id, $domain, $title);
    	}
    Posted 6 years ago on Tuesday January 29, 2013 | Permalink
  13. You can send the URL to chris@rocketgenius.com if you would like me to take a look.

    Posted 6 years ago on Wednesday January 30, 2013 | Permalink
  14. After more testing I realized it is a problem with how the form is setup and not the single input.

    I am using a 'update user' feed and not a 'create user' feed from the beta version of user registration. I think there is a gf filter that isn't firing with the update user option selected when creating a new site. Seemingly the gform_site_created is never going off.

    Posted 6 years ago on Wednesday January 30, 2013 | Permalink
  15. Correction, the function above IS firing, but the function I have up there is not receiving the $entry object. Ideas?

    Posted 6 years ago on Wednesday January 30, 2013 | Permalink
  16. There seems to be an inconsistency in the documentation. The usage for the hook explained at the top of the page included 5 arguments being sent:

    [php]
    add_action("gform_site_created", "custom_user_validation", 10, 5);

    $site_id
    $user_id
    $entry
    $config
    $password

    The example at the bottom of the page shows just two, which is how you are using it. Can you try sending them all and see if it works then?

    I will bring up the inconsistency in the documentation to the development team.

    Posted 6 years ago on Thursday January 31, 2013 | Permalink
  17. Yes, still no response. I have been troubleshooting by sending out the vars and the $entry is not there.

    add_action("gform_site_created", "modify_domain", 10, 5);
    function modify_domain($site_id, $entry) {
    $title = "/" . $entry["1"];
    wp_mail('---', 'Signup', $title.' and '.$site_id.');
    update_blog_option ($site_id, 'siteurl', $title);
    }

    Posted 6 years ago on Thursday January 31, 2013 | Permalink
  18. This line:

    function modify_domain($site_id, $entry) {

    Should have 5 arguments. Please see the edited documentation page for the arguments and their order: http://www.gravityhelp.com/documentation/page/Gform_site_created

    function modify_domain
      ($site_id, $user_id, $entry, $config, $password) {
    Posted 6 years ago on Friday February 1, 2013 | Permalink
  19. Sorry for slow response, I am not getting notified of new posts

    Okay, so that seems to correct the entry issue :) , unfortunately that is not a usable solution :( it updates the site url, but you cannot update 'home' or path with the update_blog_option so it can't do the work.

    After more testing it seems that multisite never accurately creates a new site with the beta release of the user registration add-on ( the "/" is missing somewhere in there) so this is a larger problem than I thought.

    Posted 6 years ago on Friday February 1, 2013 | Permalink
  20. Let me bring this to the attention of the development team for their input. Thanks for your troubleshooting.

    Posted 6 years ago on Friday February 1, 2013 | Permalink
  21. Hello, I just wanted to see if this has any developments?

    Posted 6 years ago on Tuesday February 5, 2013 | Permalink
  22. I heard back from one of the developers today. They were unable to duplicate the issue you're having. I have a later version of the User Registration add-on for you to try. Please email chris@rocketgenius.com and I will send it to you. Please reference this topic in your email.

    If the new version does not work, we need you to do the following:

    Check for theme and plugin conflicts using these instructions http://rkt.gs/testing

    If nothing is found there, please remove any custom code you're using in functions.php and see if the site is created properly.

    If none of that helps, we will need to take a closer look. But please try these things and report back with your findings. Thank you.

    Posted 6 years ago on Tuesday February 5, 2013 | Permalink
  23. Upgrading to 1.5.beta1.11 seems to have resolved the issue for this member.

    Posted 6 years ago on Tuesday February 12, 2013 | Permalink
  24. Yup, thanks for all your help Chris! and Thank the developer who pitched in too

    Posted 6 years ago on Thursday February 14, 2013 | Permalink

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