Skip Navigation

[Resolved] Registration system we previously had working has broken

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.

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 8 replies, has 2 voices.

Last updated by lesleeM 1 year, 5 months ago.

Assisted by: Minesh.

Author
Posts
#2606725

Luo Yang previously provided tremendous assistance for us with setting up a Ride Registration system. If he can look this over, that would be great. We are now finally ready to launch this new website and conducting some final tests, but I'm now seeing that the registration system is broken. I didn't change anything with it to my knowledge. It was previously tested and worked fine. I've been working on developing other functionality and content on the site, but now the Registration system is broken.

Specifically, it looks like the Relationship between the Registration and the Ride page from which the Registration form is submitted is broken. The Registration content types are getting created, but they do not have the Relationship established between them and the Ride page they originated from.

When we had this working, our Registration titles were automatically generated using custom code you helped us with. That code provided titles in this format:

[Test Ride] Registration – [test name 1] [11/03/2022]

In the first spot, the title of the Ride page where the form submission originated from would appear, followed by static text saying "Registration - " Then in the second spot, it would pull the name submitted by the Name field on the Registration form and then in the last spot it would display the date the Registration was submitted. That was working perfectly before. But now, when I submit a Registration, the title that results from this is:

[] Registration – [test name 1] [05/15/2023]

So the form is not acknowledging where it used to populate with the Ride Title. No Relationship gets established between the Ride and the Registration.

I'm guessing I may have messed up what was working before when I was trying to get something else to work on the site. Can you assist with re-establishing the relationship here?

This is also evidenced by us having a View that previously would display a list of all people that Registered for a Ride that would display under where we have the Registration form on the Ride page template. That was working before. The query filter on that View says "Select posts in a Ride Registrations relationship that are related to the Post where this View is shown.". Now, when I submit a Registration, my name does not get added to the page by this View. It just continues to show No Items Found. I think this is because the relationship between Ride and Registration has been broken somehow.

Any assistance here will be hugely appreciated. This was very important new functionality that I was *extremely* happy to achieve with your previous assistance. My disappointment level with seeing this being broken now is very high. I seriously hope we can get this working again. Let me know anything you need me to do.

#2606729

I'm now seeing that this is not *entirely* broken. One of our board members testing the Registration system did see her name get added to the specific ride she registered for here:

hidden link

So it's possible that the fix won't be as difficult as I'm currently fearing.

#2606787

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

As you claim it used to work, have you added the custom code shared by Luo to your live site as well that should generate the automatic title for your submitted form?

Can you please tell me what exactly is not working and share the steps I will have to follow to reproduce the issue with problem URL 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.

#2606983

Yes, the code he provided is still present. If it wasn't then none of the elements would be working to define the Registration Title.

What is specifically wrong is when we had it working Registration titles looked like this:

[Test Ride] Registration – [test name 1] [11/03/2022]

Now it is providing titles like this:

[] Registration – [Kenny] [05/16/2023]

So the Ride page title is no longer passing. The Name field and the date field are working fine.

Here is the edit page for this form:

hidden link

The [wpv-post-id item="$current_page"] code is still present in the Ride Registration field that Luo had us set up (or set up for us).

Here is the ticket where he helped us so you can see everything that was done/discussed:

https://toolset.com/forums/topic/the-registration-title-field-could-be-automatically-generated-by-the-system/

Here is the registration-title custom code he provided:

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

<?php
/**
* Snippet to create Registration title using fields to show Ride Name, Name and Date fields as title, ).
*/

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

// Put the code of your snippet below this comment.

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);

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

Something I've done between then and now has broken this on the [%1$s] and $parent_ride_title parts of this. But I have no idea what I might have done wrong to cause this. I've worked on so many different elements on this site after this functionality was working and anything could have done this. I didn't notice it was broken until now doing our final pre-launch testing with the full involvement of the club's board. I thought I still had this working because I don't think I messed with this code since it was working, but when they did their tests, I saw this problem.

#2606985

Backup done and access given in one of the other tickets. Let me know if you need me to resend the credentials.

#2607017

Minesh
Supporter

Languages: English (English )

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

Can you please test now and let me know that if it back to work.

I've adjusted the code added to the "Custom Code" section for the code snippent "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 = toolset_get_related_post($post_id, 'ride-registration', 'parent');
   // $parent_ride_title = get_the_title($parent_ride_id);

 $parent_ride_title = $_REQUEST['parent-post-title'];

$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, 3);
#2607193

PERFECT! Thanks hugely as always. Do you have any insight on why this functionality broke from the previous code? Was it something I did wrong somewhere? I'm asking in hopes of learning so I don't repeat any mistake I may have inadvertently made.

#2607389

Minesh
Supporter

Languages: English (English )

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

I do not have any site history and I do not know what changes you made. But the solution I shared will work without any issue.

You are welcome to mark resolve this ticket.

#2607399

My issue is resolved now. Thank you!