Skip Navigation

[Resolved] Split: Post form notification e-mail not showing toolset fields – another issue

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 18 replies, has 2 voices.

Last updated by lesleeM 1 year, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2607385

OK, that worked partially. I think your code for supplying the correct ride title in the e-mail is perfect. But my testing has revealed one more problem situation with the Registration system. Feel free to consider this ticket resolved and split this reply into another ticket for that.

The remaining issue with this ticket now lies in how the Post Form/Relationship handles things when a Guest user submits the Registration form as compared to when a logged in user submits the same form. When a Guest user submits a Registration form, the e-mail notification says:

Kenny-test has registered for your ride.

But when a logged in user submits the Registration form, the e-mail notification correctly says:

Kenny-test has registered for your Ride of Silence ride.

I used

hidden link

for the second test because my user had already registered for the other ride we were using to test. Your code worked perfectly there when I was logged in.

But it wasn't just your code that didn't work for the Guest user. I think your code is actually good there too, but something else is broken for the Guest user to cause the Ride title to not appear in the e-mail notification. When I submitted this test, the new Registration content type post was created on the back end. But the notification triggered here did not include the Ride title. But also, the View that shows who has registered did not include a listing for that registration at all and nothing is showing on the Ride edit page for that Registration in the Ride Registrations section. So the guest user Registration is being ignored completely by anything relying on the relationship. The only thing working for Guest Registrations is the post is getting created as expected.

I think whatever is causing the Relationship related functions to not work for the Guest user is also what is causing your code in this ticket to not work. I think if I'd see the Guest user Registration in the View showing all Registrations and see the Guest user Registration present on the Ride edit page, then your code on this page would have produced the correct e-mail text with the Ride title included.

Is there any setting I've missed that allows Relationships to work on something like this for Guest user submissions?

#2607401

Let me know if users MUST be logged in for the registration system to work. I'm hoping we can allow guest users to register though because the nature of our club has it that people will often come to our rides just from finding out about them on the site, but they don't actually join the club as a member until later. Forcing people to be logged in before they can register for a ride will make this functionality less valuable because guests aren't likely to want to go to the trouble of creating a user account. We can allow them to create a user account without forcing them to pay for membership, but I just think most casual end-users won't want to do that. If we keep ride registration quick and easy where they just have to send their name and e-mail on the Registration form while they are looking at the ride, I think that will have the best results for us.

#2607491

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You are explaining the whole scope of your project (thank you for sharing all your concern with detailed information) but we are here to help you to fix the issue but not to code your site as per our support policy.

Whatever flow you decide for your site you should work on it and if you have any issue and especially you think the cause is Toolset we are more than happy to help. As a supporter what we need is what is the problem URL and what steps we need to follow to reproduce the issue if any and admin access if required.

Without creating a user account how can we get the user ID for the user that you may be used for reference. I see you are using auto-login script in the "Custom Code" section and I'm bit confuse here with all too much information you shared and I'm not sure what way you want to go.

Can you be specific with your requirement and tell me what way you would like to go and send me all required information about with what link I can perform the test and see the issue and admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2607555

And then if you do the same steps I mentioned in the previous post when you are logged in, you'll see that your Registration works perfectly in that the Registration gets added, the relationship gets added to the Ride, and your name and e-mail show up in the View display on the Ride page. Basically compare what happens to a Registration when you are logged in as compared to a Registration as a guest. It appears to me that relationships don't work when the child post content is created by a guest user submitting a post form. But it could be it is that way by design and for a reason. I'm not sure about that.

#2607843

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The issue seems that it is due to the parent field you have hide on the following form:
=> hidden link

Due to that the parent ride was not able to connect to the parent ride where the form is available to submit.

So, I've added the generic hidden field with slug "@ride-registration.parent" just before the submit button that will hold the parent ride ID and I can see now the post is connected to the parent post.

Can you please confirm it works as expected now.

#2607845

It says that you are editing the form and it's asking if I want to take over. Is that OK?

I remember that we had a hidden field on there that Luo set up that was part of what was needed to get the Registration title to structure in the format we were trying for. Was that the field you're talking about or was there something else?

I'll see how it is now after it's OK for me to take over. I don't want to go in there now in case you are still looking at something in there.

#2607847

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes you can take over it and you are welcome to mark resolve the ticket.

I'll start working the following ticket now.
- https://toolset.com/forums/topic/post-form-e-mail-notification-recipients-question/

#2607869

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please confirm its working as expected now.

#2607895

Still not working for guest registration on this end. I set up a new ride to test on here:

hidden link

Registering when logged in with my admin user worked. That's the registration you see on the page. But registering as a guest still didn't work.

Here is the Registration done on that ride when logged in:

[Test Ride] Registration – [Kenny] [05/18/2023]
hidden link

You can see that the relationship worked with that submission and the Ride title is included in the Registration title (first set of brackets).

And here is the Registration done on the same ride as a guest:

[] Registration – [Test Guest] [05/18/2023]
hidden link

The relationship to the Ride is still not getting established for guest Registrations.

------------------------------------------------------------------------------------

I don't know if the additional information I'm going to give below will be helpful to figuring it out or not, but I'll provide it in case it does point you to something helpful.

I initially set up this Test Ride with the date January 1, 2023 so it would not appear on the calendar pages. We have the calendar pages to show future rides, not past rides. When I set it up with that past date, the Registration worked the same way for the logged in Admin account as it is doing for guest Registations. Here is the Registration done with the logged in admin account then.

[] Registration – [Kenny] [05/18/2023]
hidden link

The relationship didn't work there either.

Then I changed the start date of the ride to 07/07/2023 just to see what would happen. After I did that, the logged in user was able to Register. That's *highly strange* to me that the start date field would impact this, so I thought I'd let you know about it here.

Note that it is perfectly OK if it stays like that because we don't need people to be able to Register for past rides they access through our archive. It's better if they can't register for past rides and seeing this is leading me to probably wanting to add conditional display for the Registration form to only show it on the Ride pages so long as the Rides are future Rides. I'll do that if/after we can get everything working. I just thought I'd give you this information in case it will help with determining why the relationship isn't working for Guest user Registrations. The Guest user submission is not the only unique condition causing this breakage of the relationship.

#2608085

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've adjusted the code again to the "Custom Code" section for the code snippet "registration-title" as given under:
=> hidden link

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 = $_REQUEST['_cred_cred_prefix_cred_container_id'];
    $parent_ride_title = get_the_title($parent_ride_id);

$post_title = "[".$parent_ride_title. "] Registration - [".$name."] [".$date."]";

 ///  $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, 2);

Please make sure to delete the cache before you test and make a hard refresh once using ctrl +F5 key and check that its working as expected now.

#2608131

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Once you confirm that its working I will check with the another issue that is pending.

#2608379

AWESOME!!! Looks good this time. Guest user registration relationship with the ride worked this time and the view worked to add the registered rider to the list. You can see that here:

hidden link

#2608381

Can we keep this one open until the other issue is resolved as well, just in case something with this breaks again? What was it that you did here to fix the relationship issue?

#2608713

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As shared, I've adjusted the code you see with my previous reply:
=> https://toolset.com/forums/topic/split-post-form-notification-e-mail-not-showing-toolset-fields-another-issue/#post-2608085

You are welcome to close this ticket once you see it working as expected.

#2608841

I see your code, but I have no idea what in that actually made the relationship work as opposed to not working previously. My level of understanding is that this code generates the title of each Registration pulling the Ride title, name field from the form and date submitted from the form. I'm guessing there is something in how you've defined this that doesn't interfere with the establishment of the relationship where something present in the code before was breaking that for guest users only. But I'm not sure which specific bit of the code would do that. Just trying to understand things better. Is it that sanitize title section that did the trick?

I'll mark this one resolved when the other one still pending works too because there seems to be some possibility of one fix breaking the other in some way. Just being cautious. Thanks HUGELY as always.