Home › Toolset Professional Support › [Resolved] The next question is to see if there is any way to set up a button Ride
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
This topic is split from https://toolset.com/forums/topic/the-registration-title-field-could-be-automatically-generated-by-the-system/
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 14 replies, has 2 voices.
Last updated by lesleeM 1 year, 11 months ago.
Assisted by: Luo Yang.
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.
Hello,
It is is possible within Toolset plugins, you can try these:
1) Create a custom post type "Notification"
Setup one-to-many relationship between post types "Ride" and "Notification"
2) In the single "Ride" post, display a post form for creating new child "Notification" post, in this form, display:
- The post content field
- Submit button(Send button)
The email address list field is not required in this case, you can use custom codes to get them and put them into recipient.
- Follow our document to setup the email notification:
https://toolset.com/course-lesson/send-notifications-when-someone-submits-the-form/
3) Use filter hook "cred_notification_recipients" to trigger a PHP function:
- Get the parent "Ride" post ID
- Use above parent "Ride" post ID to get all related child "Registrations" post IDs,
- Use those "Registrations" post IDs to get all email field values, and put them into the recipients
More help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
Please let me know if you need more assistance to setup it.
Dude, I just needed to say here that you're mind blowingly good at all of this!!! I read your replies and my head explodes initially just trying to keep up with your thought process. From the initial reading, I need to say this is phenomenal that it looks like we're going to be able to do this. But give me a bit to try to follow your instructions first and then fully understand your instructions second. I generally have to actually do something before I understand it.
I'm just proud of myself that I was able to take the ball you provided and run with it on the Registrations system so I didn't have to ask you more questions about it. 😉 I'm trying my best to keep what I ask to a minimum here because I feel like we're taking advantage of your generosity with all the help. I'm hopeful that the unique usage questions I've been getting solved through these tickets for all these sites I handle are providing you with helpful information from the perspective of site developer's needs that will allow you to further expand your awesome plugin to provide more functionality for cases like mine.
This experience seeing the power of Toolset Forms and Relationships has opened up the possibility that I can provide functionality for another of the sites I've been working on that I previously thought wouldn't be doable or would require complete custom coding. I had that large lightbulb turn on over my head after seeing your solutions on the Registrations. I'm going to try to tackle that next once this Rides system is done. I think a lot of that functionality can be done with Toolset Forms and it is possible that very little custom coding will be needed.
More on this Notifications addition to the Registrations as I go through your instructions and try to do everything.
OK, please update here if you need more assistance for it.
OK, I have done all the steps in your instructions above. You can see what I've done here:
hidden link
Scroll down to the header that says Send Ride Notification and click the Open Ride Notification Form link
I have a field for Notification Title and Notification Content. That Ride Notifications dropdown field was in the form when I set it up and I wasn't sure if it was needed so I left it there. Let me know if it is OK to remove that.
The Ride Notification form is here:
hidden link
I have it set up to send an e-mail notification, but the part that is lacking is how to get the content of the Ride Registrations view where I have the e-mail field displaying as a comma-separated list to be used as the recipient list for the notification e-mail. If you can provide that, I think we'll have it.
Let me know if you see anything I've done incorrectly from your instructions. I used your form creation tool's Test E-Mail to send myself a test and it worked. I still need to test it from the front end, but I'm not sure what to put in the Notification e-mail recipients section. I could just send to my specific e-mail address to test that, but I'd rather wait to see if we can get it to send to everyone that has registered.
As I mentioned above:
https://toolset.com/forums/topic/the-next-question-is-to-see-if-there-is-any-way-to-set-up-a-button-ride/#post-2489237
You don't need to expose Registrations users email address to "Ride leader" users, you can use custom codes to get those email address, please confirm it, then I can setup a demo in your website, thanks
Absolutely confirmed.
I set up the comma separated list of just e-mail addresses so we could do the Notifications manually and the ride leader could just copy and paste the e-mail addresses into an e-mail. That was the minimum that I was hoping to achieve and I wanted to establish that I could do that.
If you can get us to the maximum here to have it automated where the Ride Leader just submits the form and it e-mails to all the people that completed the Registration form, that would be FANTASTIC!!! I will remove that comma separated list from the page once however you are saying to do it is working. I'll try to set up the display of riders that have registered for the ride to only show on the page for Ride Leader or Admin users as well, but I'll do that later.
Thanks for the confirmation, I have done below modifications in your website:
1) Install plugin "Post SMTP Email Log", so we can trace the email logs
2) Edit the post form:
hidden link
enable option "Send notification to the post author"
3) Add one new custom code snippet "notification-recipients":
hidden link
with below codes:
add_filter('cred_notification_recipients', 'modify_recipients', 10, 4); function modify_recipients($recipients, $notification, $form_id, $post_id) { // Check notification name matches target notification if ( $form_id == 2327 && isset($notification['name']) && 'Ride Notification' == $notification['name'] ) { $ride_id = toolset_get_related_post($post_id, 'ride-notification'); $registration_posts = toolset_get_related_posts( // get posts related to this one $ride_id, // Relationship between the posts 'ride-registration', // Additional arguments [ // Get posts where $writer is the parent in given relationship. // This is mandatory because we're passing just a single $writer post as the first parameter. 'query_by_role' => 'parent', 'role_to_return' => 'child', 'return' => 'post_id' ] ); foreach($registration_posts as $registration_id){ $address = get_post_meta($registration_id, 'wpcf-email', true); $name = get_post_meta($registration_id, 'wpcf-name', true); if(!$address){ continue; } // Add a BCC to registration email $recipients[] = array( 'to' => 'bcc', 'address' => $address, 'name' => $name, ); } } return $recipients; }
Test it in frontend:
hidden link
fill and submit the "Send Ride Notification", check the email logs:
hidden link
It works fine, I can see all email address in the Bcc field, see my screenshot Bcc.jpg
TOTALLY AWESOME!!! Thank you so much! I tested it by first adding one more registration with another e-mail that goes to me. That's the first e-mail now showing on the Test Ride page:
hidden link
I then sent another notification and I received it at the newly registered e-mail.
The only thing left here that I found curious was the BCC showing in the email log. If you click View under Testing Ride Notification System Notification, you'll see the following as the BCC field:
test name 1 <123@123.com>,test name 1 <123@123.com>,Kenny Moore <kmjunk@cfl.rr.com>
So my question is why is this 123@123.com one that you tested with showing up twice now? It seems like the address I added should be on here. but it isn't. This is definitely odd to me because I did receive the notification email at that address. Any idea why it would do this?
Thanks so much again!!! It really is awesome what all can be done through Toolset with some custom code help. This is better than getting the same functionality through The Events Calendar because this way we have FULL FLEXIBILITY of doing whatever we need with the data like the Views I set up under the forms.
For the new issue:
So my question is why is this 123@123.com one that you tested with showing up twice now
Please check the parent "Ride" post:
hidden link
in section "Ride Registrations", there are two child "Registrations" posts with same email address: 123@123.com
Please disconnect one, and test again
Oh, OK. I didn't realize you had two of them in there. It was still odd that the new e-mail address didn't appear in there, but was delivered successfully regardless. I just tested again and all three e-mail addresses that should appear in there are present and the e-mail was received. So I'd say we have this done now. I'll do some further testing and will let you know if I see further weirdness anywhere with that. Can we keep this ticket open for a bit longer? I think it's resolved, but I want to do more testing across multiple Rides instead of just on the one Test Ride post.
I've learned a lot through the setup of these registrations and notifications. I will next have a pretty complex system to set up for another of the sites I'm working on using Toolset. I'm thinking what I've learned here will get me pretty far into the setup of that system. So thanks hugely for expanding what I can see as doable using Toolset. I still couldn't have come close to doing this without your custom code though. I'm hoping what I've learned so far will get me pretty deep into the setup of the next system to where I won't have to request too much more support like this. But that system is more complex than this and something that I thought would be impossible for me to achieve for that client until seeing these Registrations and Notifications systems working here. Now I think it is possible.
Note that I'll have more sites in the future that I'll get to purchase Toolset too. The big thing is this allows all the sites that I've previously kept on Drupal because of the Views module being needed to be able to successfully migrate now to WordPress. Now that I'm seeing this level of functionality being possible, I'm now thinking your plugin is even more flexible and sophisticated than Drupal Views, but that's thanks to your willingness to assist with setting up certain functionality requested like this.
Can I request you in a support ticket when I'm ready with that next system? I'll identify myself as the guy that you set up the Rides Registrations and Notifications system for on this bike riding club site. I think you having the recollections of what we did here will prove helpful towards that next system setup. There will be another Toolset Form involved with that which will have to pull multiple e-mail addresses from elsewhere as the e-mail recipients. I'm thinking that will be one thing where I'll need some help with it. But I think I'll be able to get much of the rest done myself after seeing this.
I have marked this thread status as "Waiting for feedback", you can update here if you need more assistance.
Yes, you can request me in a support ticket, but I will have holiday next week, you might get delay answer.
I have one question for the other system that can be more easily asked here.
For this system, I wanted the registration title to be: Ride Name Registration - Registrant Name - Date
You used this code for that.
add_action('cred_save_data', function($post_id, $form_data) {
if ($form_data['id']==2083) { // speccific post form ID
$name = get_post_meta($post_id, 'wpcf-name', true);
$email = get_post_meta($post_id, 'wpcf-email', true);
$date = get_the_date('m/d/Y', $post_id);
$parent_ride_id = toolset_get_related_post($post_id, 'ride-registration', 'parent');
$parent_ride_title = get_the_title($parent_ride_id);
$post_title = sprintf('[%1$s] Registration - [%2$s] [%3$s]', $parent_ride_title, $name, $date);
$slug = sanitize_title($post_title);
wp_update_post(array(
'ID'=>$post_id,
'post_title'=>$post_title,
'post_name' => $slug
));
}
},10, 3);
For the new system using this same approach, we want the Vote title to only be:
Freelancer Name - Voting Board Member Name
with no date added. We don't have an e-mail address field on the voting form, so I deleted that from your code.
I've gotten this partially there with the following code:
add_action('cred_save_data', function($post_id, $form_data) {
if ($form_data['id']==7956) { // speccific post form ID
$name = get_post_meta($post_id, 'wpcf-name', true);
$parent_freelancer_id = toolset_get_related_post($post_id, 'freelancer', 'parent');
$parent_freelancer_title = get_the_title($parent_freelancer_id);
$post_title = sprintf('[%1$s] Board Vote - ', $parent_freelancer_title, $name);
$slug = sanitize_title($post_title);
wp_update_post(array(
'ID'=>$post_id,
'post_title'=>$post_title,
'post_name' => $slug
));
}
},10, 3);
But I'm not sure how to code this to pull the Voting Board Member Name . This data should pull the username of the author of the Vote post form submission which should be placed immediately after the bit that says Board Vote - . I'm not skilled at PHP and can only do minor edits like I've tried to do here with some success. Other than this, I believe I have this step on our next system completed. I'll post subsequent questions about that with that user account, but this one seemed more easily doable here and made more sense to keep it together with this one since we already were using this bit of code. Thanks again if you can get me past this hurdle. I've done pretty well setting this up myself using your same approach. I'm glad it looks like my only remaining question to emulate this will be what I think/hope will be a pretty simple code tweak for you to show me how to pull the post author username.
New threads created by Luo Yang and linked to this one are listed below:
https://toolset.com/forums/topic/i-have-one-question-for-the-other-system/
I assume the original question of this thread is resolved, for other new questions, please check the new thread here:
https://toolset.com/forums/topic/i-have-one-question-for-the-other-system/
My issue is resolved now. Thank you!