Home › Toolset Professional Support › [Resolved] The Registration Title field could be automatically generated by the system?
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
This topic is split from https://toolset.com/forums/topic/event-registration-functionality-in-toolset-custom-content-template/
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Hong_Kong (GMT+08:00)
This topic contains 12 replies, has 2 voices.
Last updated by lesleeM 2 years, 1 month ago.
Assisted by: Luo Yang.
I went ahead and set up a Post Form. I tried to set up all the fields we want with this and have it as close as I think I can get it. I'm not sure if this is the right way to do this, but I figured I would go ahead and set up the form. The one issue I had was I couldn't figure out what to do with the Registration Title field. End users aren't going to know what to call that, so I decided to use Your Name as the label for this field. That way end users will just be entering their name here, which is one of the fields we wanted to have anyway. It would be better if the Registration Title field could be automatically generated by the system instead of provided by the end user. If that's possible, we would have the Registration Titles have the format of:
[Ride Post Title] Registration - [Name] [Date].
If that is impossible, then maybe we could provide instructions through an HTML content element for this field for the end user to title it the way we'd like it to be and then set up Your Name as a separate Single Line field.
Please let me know if I'm moving on the right path with either of these efforts.
Hello,
It needs custom codes, for example, after user fill and submit the post form, use action hook "cred_save_data" to trigger a PHP function:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
In this PHP function:
1) Get those custom field values:
https://developer.wordpress.org/reference/functions/get_post_meta/
2) Generate the post title as want you want, and save it into database:
https://developer.wordpress.org/reference/functions/wp_update_post/
For your reference.
For this, do you have anything where we can pay you to do this and setting up the registration system I'm trying to do from the original thread? I'm not sure how things would go with posting it as a job in your Toolset Contractors section. We could try that. But if you'd be able to set this up as needed, I can see how much my client would be willing/able to pay to get it and run it by them. If your price and their cost ceiling work out, then we'll do it. I'm highly confident that you'd do it right and quickly. And I think if I can see it done correctly once, I could then emulate what you do for other needs.
I fear getting everything the way it ideally needs to be set up is going to be beyond my skill level. I'm not a PHP programmer. I'm only good enough where I can do some tweaks to existing code, but not at a level where I can create my own functionality. I think it's going to take me quite awhile to learn your Toolset Forms functionality. I'm going to have to go through every one of your posted lessons and then try to apply them in a real world application on this site or one of the others I'm working on to get to a higher level of confidence. I learn best by doing, not by reading or watching, so I'll have to apply your lessons to something needed on one of these sites to get to a real level of understanding.
Since it is a custom codes issue, please provide a test site with the same problem, fill below private message box with login details, also point out the problem page URL and form URL, I need a live website to test and debug.
Thanks for the details, I can login into your website.
I assume we are talking about the post form "Ride Registration Form":
hidden link
It is a post form for creating new "Registration" posts, but there isn't parent "Ride" post field in it.
In the frontend of single "Ride" post, for example:
hidden link
You are displaying two forms:
- Relationship form
- post form for creating new "Registration" posts
But it can be done with only one post form: Creating new child Registration form, see our document:
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/
Is there any special reason to use two forms for it?
And according to our support policy, we prefer one ticket one question, for other new questions, please create new threads for them.
I have two forms simply because I'm trying to learn the system and am not sure what I need to do. I set up the Relationship Form first to see if that's how to do it, but ran into the dead-end of not being to add my own fields. So then I tried it with a Post Form. I have to go through all your lessons in the documentation section before I'll have any solid level of understanding with this. But that's going to take me time to get to that because I'm being kept very busy with other projects I'm trying to get over the finish line to launching them, including two others where I'm getting support from you guys on issues with things where I'm using Toolset for them. That limits my ability to concentrate to the level I need to for learning something new that is very complex. I'll be setting this current site up gradually for now as I have time. Once I get those other projects finished and launched, then I'll be able to turn my full attention to this site and will have more time to learn Toolset Forms properly.
But I thought if we could pay you something extra to set this up, that would greatly accelerate my learning curve with Toolset Forms to see it done as it needs to be done one time with this instead of going through a lengthy trial and error learning process. I could study what you do with our real world example and then I would understand the system much better that way and hopefully be able to create my own additional applications as needed after that.
Registration is the content type I created. I created a Relationship making that a one-to-many child of Rides and called it Ride Registrations. Then I tried creating a Relationship form unsure of if that was the way to do this, but that didn't allow me to add my own fields to the form. So then I created a Post form and added that. I didn't eliminate the Relationship form because I wasn't sure if I was just missing something with using that. I planned to figure out which one was the way to go with this after going through all your lessons. I was going to use each one of those forms to figure out the capabilities of each type of form and then delete the one that we didn't need here later.
I'm a total newbie to using Toolset Forms here. I've learned enough about Toolset functionality to get a long way with it with a LOT of help from you guys. But this is my very first effort with learning Toolset Forms. And I think I'm compounding the difficulty here by trying to learn on what will be a fairly complex setup. I'm not starting in the shallow end of the pool so to speak. It would probably be better for me to learn the basics of Toolset Forms before trying to learn this.
There is a misunderstanding, according to our support policy, we can help you to use Toolset plugins, all supports to our client are free, if you want paid service, please check Toolset contractors:
https://toolset.com/contractors/
In your case, it is one-to-many relationship, you just need one post form to setup the child "Registration" post and relate it with parent "Ride" post, you don't need that relationship form.
I have done below modifications in your website:
Edit the post form: Ride Registration Form
hidden link
In section "Form editor", add the relationship field "Ride Registrations", setup the default value as: [wpv-post-id item="$current_page"], see my screenshot Ride-Registrations.jpg
See the result here:
hidden link
More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
For the original question of this thread:
https://toolset.com/forums/topic/the-registration-title-field-could-be-automatically-generated-by-the-system/#post-2483469
To avoid more misunderstandings, please confirm these first:
[Ride Post Title] Registration - [Name] [Date].
I assume these:
- "Ride Post Title" is the parent "Ride" post title
Where does the "Name" and "Date" come from?
I just feel that this is too much to ask for free. I'll just go ahead and go through all your lessons to get to a better level of understanding of everything to where I'll hopefully just have to get help with certain steps rather than hoping you can do the whole thing for us. But it will take me awhile. We are at the point where I'm ready to launch another of the major sites I'm doing, so hopefully that will free me up for extensive Toolset Forms study time sooner.
I've removed the Relationship form from the Ride template since you said that isn't needed here.
I see the Ride Registrations field you have set up on the Post form is definitely helpful. Is there any way to make that field just automatically set to the current page title value instead of being a select field that end users can change? If not, then setting it to default to the current ride title as you have should be good enough. I could maybe add (do not modify this field) to the Ride Registration label there as an instruction.
I think your adding this Ride Registrations field is also going to be very helpful towards building a view that will display all Registrations for each ride individually. If we get this working, we'll want to add a View into the Ride template that will display all Registrations for that Ride. We can set up a Conditional that makes sure this Ride Registrations field equals the current ride title. But I'm sure you probably have another way to do this with the Parent-Child Relationship that will work just as well, but I haven't learned that yet. I'll set up a separate ticket if/when that step of setup is reached.
I've made a Single Line field for Name below the Registration Title field now since we may be able to define the Registration Title field another way.
As for the elements we'd like to use for defining the Registration Title field:
Ride Post title is the title of the current Ride post. That will change on every Ride post.
Name should be the name the end user enters into the Name field I've now added. I don't know if it is possible to populate part of the Registration Title field with data that isn't in the system until after the end user hits the Submit button or not. I'm sure that's the difficult part of what I'm hoping to do here. If that isn't possible to do, then I do have another approach we could use. We could require end users be logged in on active user accounts before using the registration form. If we do that, then we can pull the First Name and Last Name from the active user account profile to achieve the same thing and if those profile fields are empty, then use the Username on the account. That would work. Or we could just use the Username on the account to keep it easier. That would eliminate the possibility of allowing people to register if they aren't members though. It would be better to let everyone register and use the name they provide on this form as part of the title. I'm just thinking of alternate ways of doing this. If you can suggest any other approach that would get us to a point where we can easily find Registrations by specific individuals among a large list of Registrations, let me know. I'd expect that we may have 20-30 registrations per ride so if we ultimately have hundreds of rides in the system, finding specific Registrations without unique titles like this will be very difficult.
Date should just be the current date when the Ride Registration form is submitted. I'm guessing that should be relatively easy to include.
That way if someone filled out this form on this Ride today, what would populate as the Registration Title would be "Test Ride - Name - 11/02/22" That way each Registration would have enough relevant information in the title for an admin to be able to pick it out of a huge list of Registrations if there is any editing needed.
Thinking about this more and now I believe that leaving the Label for the Registration Title field as Your Name might make this much easier. With having the end user supply their name in the field where we want it to be, we don't have to pull that from any other source. All we then have to do is prepend and append the supplied name with the Ride Name and Date. We don't even have to have them in that order so long as all elements appear. We could just append both Ride Name and Date at the end of the provided Registration Title if that's easier.
If you agree that keeping the end user supplying their name with the Registration Title field would make it easier, then I can eliminate the Name field I created and put the Registration Title label back to Your Name. At that point my original question then would become "Is it doable to automatically add Ride Name and Date to the supplied Registration Title field?"
In your case, I suggest you try these:
1) Create a custom field group for post type "Registration":
hidden link
with below two custom fields:
- Name
- Email
You can store the original name and email values into database, it might be helpful in the future, you might need to send emails to those users
2) Edit the post form:
hidden link
1) replace the generic single line field with above "name" field
2) replace the generic email field with above "Email" field
3) Remove post title field(Since we can populate the post title with custom codes)
4) add two "HTML Content" elements to wrap the relationship field:
<div class="hidden-div"> ... </div>
in section "CSS editor", use below CSS codes to hide the relationship field in frontend:
div.hidden-div{ display: none; }
See the result here:
hidden link
5) Dashboard-> Toolset-> Settings-> Custom code:
hidden link
Add one item "registration-title", with below codes:
Test the result, for example:
hidden link
Fill and submit the post form, see the result here:
hidden link
More help:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
For your reference.
WOW! You have this issue resolved already. Incredible. I believe everything is working as it should.
Then another WOW! I've been able to figure out most of what I think I need for the next step on my own. Take a look at
hidden link
Specifically look under the following section headers:
Register for this Ride
Who's Registered for this Ride?
I think I have this set up correctly to filter the results through the relationship. Please confirm if you think I did this correctly.
So it should only display Registrations for the specific Ride page each of these is on.
I set up one View called Ride Registrations and another view called Ride Registration E-Mail List. The first one shows a table of Names and EMail Addresses for everyone registered for that specific ride. The second one shows a list of EMail addresses separated by commas.
I set up a query filter on each of these for:
Select posts in a Ride Registrations relationship that are related to the Post where this View is shown.
So now we provide a list of everyone registered on the first one and then the Ride Leader can copy and paste that second view result into an e-mail message as the To: list to send notifications manually. That's the bare minimum I was hoping to achieve with this and I think I have it.
This leads to my next question with this Registration system. Feel free to split this off into a new ticket if necessary, but I'd ask that you continue to be the person handling this one since you already know what I'm trying to do with everything here. The next question is to see if there is any way to set up a button Ride Leaders can click on that will open up a form that will send as an e-mail to the addresses in the second view. We could set up a button with the text "Send Ride Notification" that Ride Leaders can access at the bottom of each ride page in the Rides template. When that button is clicked, a form for would come up with a To: field automatically populated with the results from the second view, and then a Notification: field that would be a text area where the Ride Leader would type their notification. And then a second Send button would be needed within that form that would send that Notification to all the e-mail addresses. Is that in any way possible?
If we could do that, this Registration system will be PERFECT for our current needs.
New threads created by Luo Yang and linked to this one are listed below:
Yes, you are using correct query filters.
For other new issues, please check the new thread here:
https://toolset.com/forums/topic/the-next-question-is-to-see-if-there-is-any-way-to-set-up-a-button-ride/edit/
My issue is resolved now. Thank you!