Skip Navigation

[Resolved] Users setting many to many relationships followup question

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

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

Last updated by collinC-2 7 years ago.

Assisted by: Luo Yang.

Author
Posts
#599039

Hi, I need some extra help on the following question https://toolset.com/forums/topic/users-setting-many-to-many-relationships/. I've got the connecting form set up but I still have two issues with it. First, I need to add the band custom post type entry to the connecting form. I've got a view set up that pulls the ID of the band custom post type entry that the Band user owns. However, the value is wrapped in div tags. Is there a way to get the raw version of that so I can set the band custom post type entry field value?

Second, I want to send a confirmation message to the site owner when a band sets up an appearance at a show. I want it to at least send the message like this "The Beatles are appearing at Carnegie Hall" ("band names appears at venue name"). However, in the CRED form settings, I'm not sure how to pull that information in. I tried to select the various name fields for the custom post types but they don't return anything. I can probably create a view that pulls up the band custom post type entry and venue custom post type entry based on the submitted ID but I don't know how to pass those values to a view I might build to do this. Can you tell me the best way to set this up?

Please let me know if I can provide more information.

Thanks,

Collin Condray
Director of Technology
BlueZooCreative.com

#599184

Dear Collin,

Q1) Is there a way to get the raw version of that so I can set the band custom post type entry field value?
I assume you are going to get the post ID in the view loops, please try with Views shortcode [wpv-post-id]
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-id
Outputs the ID for the current post

Q2) but I don't know how to pass those values to a view I might build to do this
I assume you are using CRED form to create the post of child post type "appearance", and setup the email notification content with the parent "Band" post and "Event" post information, you can use specific the id attribute as "$band" or "$event", see our document:
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
To include a field from the parent post, you would use the following shortcode:
[types field="xxxx" id="$yyyy"][/types]
Where xxxx is the field of the parent you want to show, and yyyy is the slug-name of the parent. The “$” is required, as this represents a variable where the parent post name will be replaced by the post ID, internally.

#599385

Q1) Yes, I am pulling in the [wpv-post-id]. However, this only describes the band custom post type entry side of the connecting form. I need to pull the ID of the associated event.

I have a view that returns the associated Event ID that I want. However, the view wrapped in a div tag. I just need it to return the value. How do I make a view just return a value?

Q2) I've done as you suggested and added those tags that reference the parent information. However, when I do, I don't get a confirmation email. When I exclude the tags, I do get a confirmation email when filling out the form.

The connecting Appearance custom post type entry is created so that part appears to work. The parents for the Appearance custom post type entry are not set. In my form, I'm passing the ID of the parent post, however, when I edit the individual Appearance custom post type entry through the dashboard, and look at the dropdown entries on the parent, I see the parent post title. Shoud I be using the parent post title in my cred form or the parent post ID to connect them.

Please let me know if I can provide more information.

Thanks,

Collin Condray
Director of Technology
BlueZooCreative.com

#599738

Q1) Yes, you are right, the shortcode [wpv-layout-start] ... [wpv-layout-end] will output a extra HTML div tag, I suggest you try the solution of another thread to hide it:
https://toolset.com/forums/topic/i-need-the-ability-to-create-a-loop-without/#post-328540

Q2) It is abnormal, I suggest you Enable PHP debug mode, copy and paste the debug logs here
PHP Debugging
In case you think that Types or Views are doing something wrong (what we call a bug), you should enable PHP error logging. Again, edit your wp-config.php file and add the following:

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
This will produce a file called ‘error_log.txt’ in your WordPress root directory. Make sure that the web server can create and write this file. If it cannot, use an FTP program to create the file and make it writable to Apache (normally, user www-data).
https://toolset.com/documentation/user-guides/debugging-types-and-views/

#600022

Q1) Unfortunately, that shortcode didn't work for me. I still was still wrapped in tag https://pastebin.com/jT4rNAXk.

However, it appears that the CRED form needed the name of the post in those fields instead of the ID. For the Band, I used the current username. For the event, I pulled the information using the parent id.

Q2) I've added your settings to the wp-config.php file and I wasn't able to write to the error_log.txt. I changed the permissions to 777 and it still wouldn't write to the file. Is there another approach I can take on this?

One other question I had is how can I create a view to search my intermediate custom post type on both parents. I can create a view that matches only one parent (ex. band is The Beatles OR event is Carnegie Hall). Is there a way to create a view that returns which posts match both parent (ex. band is The Beatles AND event is Carnegie Hall)?

#600046

Q1) Sorry, I think I spoke too soon. Apparently, I do need to find out how to remove the div from a view result. Can you help me with that again?

Q2) I think I'm not passing values to the CRED form. I've been trying to hardcode values to get something to submit for debugging purposes. Where does the actual value go? In the value field or the select_text field?

event-requirement Parent: [cred_field field='event-requirement_id' value='[wpv-post-id]' select_text='--- not set ---' class='form-control' output='bootstrap']

I used the Auto-Generate form to create these fields. Do they need to be drop down fields?

Please let me know if I can provide more information.

Thanks,

Collin Condray
Director of Technology
BlueZooCreative.com

#600049

Q1) I figured this one out. I wrapped more of the hide-tag around the view output and removed some whitespace and I was able to set the values correctly.

Q2) I'm getting the following message in the error_log.txt file "PHP Notice: Undefined offset: 2 in /nas/content/live/hushlyst/wp-content/plugins/types-access/includes/Helper.php on line 3750". Does this help you understand what's going on?

The CRED form is creating the intermediate object and returning a confirmation message so something is working.

Please let me know if you need any more clues from my end.

Thanks,

Collin Condray
Director of Technology
BlueZooCreative.com

#600075

Fro Q2), The debug logs is related with Access plugin, isn't related with CRED plugin, in case there is any compatibility problem in your website, please try this:
1) deactivate other plugins and switch to wordpress default theme, and test again
2) If the problem still persists, please provide a database dump file (ZIP file) of your website in below private detail box, also point out the problem CRED form URL and page URL, I need to test and debug it in my localhost, thanks