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.

Allow a "Create a new site" form only once using conditional logic?

  1. I've got a form using the feed action "Update User" set up to allow an already logged in user to "create a new site" on my multisite network. I would like to use conditional logic to only display this form if the logged in user does not have a site on my network yet. If the logged in user already has created a site, I would like to simply hide the form as to only allow one site per user.

    Can this be done using a merge tag that has the user's multisite network site ID or something? This post over at gravity wiz got me thinking I might be able to pull this off, http://gravitywiz.com/gravity-forms-conditional-logic-based-on-user-login/

    Can this be done? Thanks in advance!

    Posted 11 years ago on Monday June 10, 2013 | Permalink
  2. Hi Chobson,

    Good question. This is definitely possible and although the solution I have for you isn't 100% locked down, I think it'll work for you.

    Here is the code. Paste this in your theme's functions.php file.

    http://pastie.org/8031090

    Next up, you'll need to configure a hidden field. We'll populate this field with the logged in user's blog ID.

    http://grab.by/nnCk

    The last step is to use this hidden field "User Blog ID" in the conditional logic of any field (including page breaks) that should be shown/hidden depending on whether the user has a blog on the site. The code above will populate either a "1" or the ID of the first blog it loops through that is not the root site. In other words, if the user belongs to any "blog" on the network install besides the root blog, it will populate the ID of that blog.

    http://grab.by/nnCs

    This means that we can simply check if the Blog ID is "1" to determine whether or not the user belongs to another blog. "Belonging" to a blog and being the "creator" of a blog are not necessarily synonymous but I'm guessing your case it will be close enough.

    Posted 11 years ago on Monday June 10, 2013 | Permalink
  3. Yes! Awesome. Thank you. That worked beautifully.

    Posted 11 years ago on Monday June 10, 2013 | Permalink
  4. David Peralty

    Glad you got it sorted out.

    Posted 11 years ago on Tuesday June 11, 2013 | Permalink

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