Conditionally create a subsite when registering

By: Jan Siwinski | Asked: 05/16/2024
ForumsCategory: How-toConditionally create a subsite when registering
Jan Siwinski asked 5 months ago
Is there a way to conditionally generate a subsite when a user registers on your site? Depending on the membership level?

At the moment my development is set up so that a different registration form is presented to the user depending on their chosen membership level. If they choose the highest level, they get a subsite, if they chose a lower level they just have an account created on the main site. Lets call these registrants Mentors.
And although that would work in practice it's not ideal.

Each of the two Mentor membership levels will need to register subscriber level Trainee members. I planned to let the would be subscribers search the site for their applicable mentor but if the mentor account registrations are between two different forms It complicates things.

So I tried to consolidate the names of the mentors into one form using the frm_after_create_entry hook, but I need to edit the code to use both forms as the source, so an array, and I keep breaking the site so that options off the table.

You can't have more than one registration action per form which would be the answer to my prayers if that restriction wasn't in place as I could then use the conditional logic option to simplify what I want.

Any Ideas I haven't thought of? 

Piecing together multiple forms to achieve a relatively simplistic task seems unnecessary convoluted.

Tia,

Jan
2 Answers
Victor Font answered 5 months ago
This is a lot to unpack and the high level explanation doesn't really explain what you want to do. What do you mean by "generate a subsite"? Are you using WordPress multisite? This is how you can create a multisite through code: https://stackoverflow.com/questions/25474978/automatically-create-site-in-multisite-wordpress-installation
Victor Font replied 5 months ago

That being said, multisites have different databases and nothing data-wise is tied to the main site.

And I have no idea what you are speaking of when you talk about consolidating mentors. Do you have a business requirements document or process flow that can be shared?

Jan Siwinski answered 5 months ago
Thanks for your answer, Victor. 

yes it’s a multisite installation. The register user action gives the option to create a subsite when registering. The difference between my two membership levels is one creates a subsite, the other doesn’t. But although the registration action offers conditional logic, it doesn’t allow a subsite to be created depending on the membership level registered. 

the consolidation refers to my work around of the problem above. I’m having to use two separate registration forms to achieve what I need. But the mentors need to be searchable. So if I have to use the work around. I need to consolidate info from both forms ( name etc) into one form to make the mentors searchable 
Victor Font replied 5 months ago

You cannot search across multisite databases without a significant amount of custom work. It can be done, but it requires a lot of database design and you're going to have significant issues to overcome when consolidating data.

Each site in a multisite installation is an independent database. Multisite shares plugins and themes, but the data is purely independent. This means that when you have forms collecting data on each site, entry ids could easily be duplicated across the sites and there's no way to reconcile which entry id is the single source of truth. Your design creates an irreconcilable conflict. To search Formidable data, all entry ids must be unique.

I could tell you how to customize MySQL to access the data across multiple databases, but your choice to use multisite renders your overall goal unfeasible. You will not be able to consolidate the data to search as you want.

You really need to rethink your system design and focus on a single site that uses a hierarchical workflow to accomplish the goals. Do you have a BRD?

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right