Home › Toolset Professional Support › [Resolved] Relationships field isn't allowing us to add new authors
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 |
---|---|---|---|---|---|---|
- | - | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 |
- | - | - | - | - | - | - |
Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)
Tagged: Setting up post relationship, Types plugin
Related documentation:
This topic contains 46 replies, has 3 voices.
Last updated by Beda 5 years, 5 months ago.
Assisted by: Beda.
Hi Beda,
This is now up and running again - I've also de-activated all plugins (but Toolset Types), and put back to the original theme.
I'm still unable to access content though - please see screenshot attached.
Need to resolve this as soon as possible, as we've now been unable to update the site in a couple of weeks.
Thanks,
Jack
Thank you, I was now able to log in at hidden link again.
I see only Types is active, and you use a native WordPress theme.
Since the native Post type "posts" is back named "posts", the relationship for "Authors" is invalid, see hidden link > Authors.
I elaborated on this already here https://toolset.com/forums/topic/relationships-field-isnt-allowing-us-to-add-new-authors/page/2/#post-1301553.
I am not sure whether you renamed that back to posts on purpose, but it will affect many things each time you rename it, and I also realize now that it is not possible with Toolset to rename the native post type - hence that was done with custom code.
In any case, since the relationship was saved for an "article" type, which now should be the "post" post type, the relationship is invalid.
I think resaving it should solve the issue, because editorial board do work, and that's a relationship that is saved for the "posts" post type, not the articles which do not exist anymore now as a post type.
If "posts" is the right post type in the "Authors" relationship, can you save this in the hidden link screen, to confirm that you can then choose authors from posts?
The problem is, it seems a renaming was done on both ends of this relationship, posts AND author post types was renamed multiple times. This can be a source of issues if the relationship is not accordingly updated for the changed Types.
Hi Beda,
Thanks for this - I think the issue is also tidied to the fact that we had a post type called Authors in Drupal, and when imported this post-type is tidied to users already.
Thanks,
Jack
I see the relationship hidden link is not yet updated.
Could you try the steps I recommended previously?
==> I think resaving it should solve the issue, because editorial board do work, and that's a relationship that is saved for the "posts" post type, not the articles which do not exist anymore now as a post type.
If "posts" is the right post type in the "Authors" relationship, can you save this in the hidden link screen, to confirm that you can then choose authors from posts?
Basically, you will need to ensure:
1. In Toolset > Post Types all post types are saved with the desired slugs.
2. In Toolset > Relationships all relationships are saved with the right slugs and connect the desired post types
3. If you renamed any of those post types at any moment, it may be possible that some data, saved while the post type slug was something else, will disappear from the list of posts.
==> I can tell you exactly what post types there are if you can send me a Database Dump (with PHP MySQL you can dump the database and send that to me), in case you suspect missing data.
Related to "Authors in Drupal, and then imported this post-type is tidied to users already", I assume you imported posts "(authors) from Drupal to a Post type in the current install (authors) and once that's done, those posts are WordPress posts, there is nothing from Drupal that could affect those.
You can test this by simply creating a new relationship between Authors and Posts, as I did here:
hidden link
In this relationship you can easily connect existing Authors to existing Posts, see as example hidden link > New Test Posts-Authors > Connect existing Author
It's most likely solved everything as soon as you save the relationships as instructed previously.
Thanks!
Hi Beda,
Can you login and make these changes please?
Thanks,
Jack
A very long, but very short:
The relationship asks for a post type named "author", and it is not possible creating such post type in WordPress, because of https://codex.wordpress.org/Reserved_Terms.
"Author" is a reserved word, and your current post type is named authors, instead of "author".
Normally renaming post types won't affect relationships, not even on your site as I tested, however, there seems to have been something that hindered the relationship from accepting the new post type name and it still expects the old "author" type.
That's the post type the relationship states to need, so we either need the post type with this slug (impossible, and never was) or we need to edit that relationship in the database so to listen to the right slug, this should be possible.
Can you please share access to PHP MySQL for this website?
I can edit the database and fix this, then we can test, and if it works we can apply the same fix on the live site (or maybe we can write a snippet that will do it for us).
I enabled a private reply.
Great! Here we are..
removed, because public...
It is a bit of a mess in this database, there are several entries (options) pointing to the same site, but with totally different content.
However, it seems hidden link is using wp_2 prefixed database.
There are many relationships in there with the same slug, the same post types.
This can NOT happen with Toolset.
To have this happening, the database needs to be manipulated either directly or with code, and Toolset does not create such duplicate entries, neither duplicate slugs: it is simply impossible doing that because the GUI would warn you.
It can be that migration is an issue.
But I think there is/was more at stake, given there are many duplicates of the same relationship, same post types and same relation type.
Since there many relationships with the same name, that types mixes those into one.
Note, it is actually possible to replicate the error you experience - but only if you head to the database, and alter the slugs of Relationships MANUALLY to match other relationships.
Note that this is irreversible, given all the connected posts will listen to an ID of relationship that is potentially duplicated (the relationship).
I've renamed them all in the database now, you see them all listed in hidden link
As you see, there are at least 5 Relationships which do the same, have had the same slug, and will confuse the code.
Note that now your relationship in posts work:
hidden link, hidden link
It seems it uses this relationship:
hidden link
Please make a BACKUP before you proceed!
Likely, you should test on testing install like the one you have, by starting to remove all other relationships.
hidden link (remove first the ones with exclamation mark).
Please be aware that hidden link is NOT the only relationship that still has posts assigned, but there is also hidden link, with several thousand posts connected, and this relationship belongs to the ones that are to be deleted, as it's a corrupted, manually added relationship as above explained.
BUT, the problem with this is that you'll lose all connections of all those relationships you delete, so you have to be careful here.
First, I suggest removing the relationship from the GUI and test if everything still works.
If so, we were lucky, if not - re-instantiate the site from the backup.
In the case you needed to restore the site, let me know, we can then try to get all the old related posts and updated their Relationship ID programmatically (maybe):
Note that we cannot generally help with this sort of problems, as they do not source from the functioning of Toolset.
But I can assist along with this, trying to recover as much as possible.
Also, the "weird" slugs the relationships have now are because I needed to differentiate them...
I can only assume these duplicates have come from when we originally imported from Drupal to WordPress as we had some issues then.
I've removed the suggested relationships after backing up, and it looks like we've been lucky.
Can we now try it with hidden link? I've deleted the relationships which aren't being used.
If this work, we'll then need to work together to replicate on the live server.
Thanks.
Any update on this?
Thanks!
Hello, I was on my weekend.
I see that "I've removed the suggested relationships after backing up, and it looks like we've been lucky."
I understand, you have now one relationship (posts/authors) left that is actually working and all data is still present as wished?
That's great.
I understand you have this same issue on many sub-sites of the same MS Install?
Then you need to figure out all the database connections as I did for hidden link
Then they all need to be renamed, so they appear in the admin. Only then you can delete them.
This is work we can't do for you, but a contractor could (https://toolset.com/contractors/), or you can do it with our explanation.
The problem is that I cannot develop or fully modify websites for Toolset users. That would be a custom development.
The issue here is not due to Toolset, as it is virtually impossible to create several Relationships in the Database using our GUI or any other method.
Can I ask how many sites you see this problem on, and mainly, why does this issue only appear after having imported to all those numerous sites?
I would suggest reviewing the import mechanism, as there clearly must be an issue with it, which you do not see while importing but only after, correct?
I can assist along the testing, and I can offer another full test on a testing site, I can even offer to do this on a live site, but I cannot fix all the sites you administrate, because custom development is not supported by Toolset Support, and this, unfortunately, falls under custom development, given the issue cannot be reached using Toolset, but surges from another process, which eventually involved custom code in the First Place.
Can you outline where this happens and if you can determine the cause of it happening?
This is important, otherwise, it will just happen again in future.
Hi Beda,
We are unable to re-import, as the import was done several months ago when we moved from Drupal to WordPress, the problem always existed since import on the older content we just never noticed until now.
If you're unable to do it, then we'll have to do in-house. Please can you create a step by step process, as we'll need to repeat this on hidden link and then 6 live sites.
Thanks,
Jack
Yes, I can assist with that.
Let's take hidden link as the example, you will proceed there according to the below steps, and if succesful, you'll have to repeat the same (after backups) on any other related site
Note that the tables, names, ID's and other details will change from site to site.
1. Determine each Sub-Site's Database Table prefix. For touchneurology.0055.co.uk, this is wp_3_
==> You can find the right Database Prefix by searching the entire database for the exact sub-site URL like touchneurology.0055.co.uk. The (only) results then will be in the options table, where you can see its prefix.
This is done in PHP My Admin.
2. Once you know the database tables where this subsite is stored in, you can look up in the respective "toolset_relationships" database table (in this case, it's wp_3_toolset_relationships) for the faulty relationship, which in our case is "author-post-author" (the slug of the faulty relationship as seen in hidden link)
==> To search, click on the very wp_3_toolset_relationships table.
This will load that table on the screen in PHP My Admin.
Then, click the top menu "Search" and search for the exact URL of the faulty relationship, in the field "slug". Submit the search with OK.
3. This will now bring up a list of all existing relationships with that precise slug.
There should be only ONE. But there will be many in the case of touchneurology.0055.co.uk there are 7 such relationships.
4. Now you need to find which of those 7 relationships are actually used.
For this, open a new tab with the PHP MySQL table "toolset_associations" (you need the right table for this very subsite, hence search for the proper prefixed table). In our case this is "wp_3_toolset_associations".
This will again open a screen with that table's contents. Now repeat the same search process in this table like for #2 above, just this time search for the ID's of the relationships found in #3 above. In our case, these ID's are:
20, 46, 72, 98, 124, 150 and 176.
In the toolset_associations table, you now need to search EACH ID in the field "relationship_id".
5. The above step #4 repeated for each ID will show a list of all Posts, connected in that relationship.
We will discover that not all relationships have posts added. Those are the ones we will be able to safely delete.
In our test case, those are the Relationships with ID 20, 46, 72, 98.
6. Hence now we can head back to the Toolset toolset_relationships table (wp_3_toolset_relationships in our case) and re-name the Slug for the Relationships with ID as found in #5 above.
We will rename those "empty", "unused" relationships to author-post-author-one, author-post-author-two, author-post-author-three etc etc.
==> ONLY the Relationships which we found in #5 should be renamed right now.
7. After this, you can head to the Toolset > Relationships menu and should now see at least 4 more relationships (the author-post-author-one, etc etc).
Delete those in the very Toolset UI.
8. Now you should be left with the relationships that actually have posts ligated to it, in the database - in our case those are the relationships with ID 124 and 2058.
Here I suggest evaluating which has MORE posts connected to it.
150 has 2058 associations
176 has 2060 associations
9. Now I'd rename the one with LESS related posts (in our case Relationship ID 150) to "author-post-author-less".
==> If there are more than 2 relationships with posts, choose then one that has most posts ligated as well, and then rename all the others.
10. Head again to Toolset > Relationships and delete the remaining relationships (author-post-author-less), so you are left with one at the end.
Note, this was done (and confirmed to be working) on the testing site hidden link, where we had no other software active.
This may be required to be done as a preparation to above steps as well on other sites.
As well, please do not forget a valid backup, and doublecheck always, you are editing the right Table (make sure the prefix is correct).
Please let me know if above steps work on the testing site hidden link as well, and do not hesitate to ask my assistance in case you get stuck at any point.
Hi Bera,
I've followed your steps but I've got a warning message on the Authors relationship as seen in the attached screenshot...
How do I move forwards?
Thanks,
Jack
Either there are still other relationships with that slug or you deleted the wrong one.
I tried to log in on the site but it gives me an HTTP ERROR 500
Can you let me see the backend of hidden link and also it's PHP Admin?
I can check if there is any left or maybe the wrong was deleted or if we just need to re-save that relationship.