Forum Replies Created
-
AuthorPosts
-
badabingbreda
ParticipantI'd like to think the method is comparable to wp_insert_post() to insert a record, if the goal is to insert/add a auto-incremented row. But the MetaBox\CustomTable\API::add() returns the number of records returned (which I guess will always be 1 if successful, 0 if unsuccessful for whatever reason) and the wp_insert_post() method returns the newly created ID or a WP_Error object.
I was expecting the MetaBox add method to return the newly created ID, but found that it didn't. I think returning either an ID or false (not successful) would be returning more valuable information.
My use case is that I use custom tables to create a model type where I store results for a taken assessment (newly created on submission, need the created ID) and immediately need that ID to store the meta (also custom table) for an arbitrary amount of question results, so not stored in columns but assessmentid,key,value format.
This marked as a non-support question, so it's rather a 'wouldn't it be more effective to return the created row ID' kinda topic.
badabingbreda
ParticipantSame here
badabingbreda
ParticipantOkay, client replied, gave me super admin privileges on the network and without touching anything else I went straight into a demo view that I had used to isolate the problem (the view mention in the original initial post). I was now able to save the template without > being saved as & gt; withing twig brackets.
I was administrator before, super admin after. Seems like a bug for multisite only perhaps.
badabingbreda
ParticipantThanks for your reply. I have yet to hear back from my client. I asked him to create a staging copy of the site. I there disabled all plugins that I could but that didn't help. Something that didn't seem of importance was that it's a multisite environment. I asked him to assign me the role of super admin. After he did so, the problem went away.
This was Friday morning, I reported to the client about my findings but he has not replied yet. I mean to test the theory and have him strip away the extra privileges on staging, and grant me them on live. Was going to report back as soon as I knew more, but it's undetermined when that will be.
badabingbreda
ParticipantThat's just it, it's on a live site. It just started happening after I was informed that a Twig template wasn't rendering, but I'm unable to edit it and troubleshoot because of this.
Here's what happens when I save a view (this isn't the view that's not working, but if I edit that one it will just mess it up more than it already is):
badabingbreda
ParticipantLOL, double slashes were automatically removed in my post. They were there where I mentioned them, I swear!
badabingbreda
ParticipantThanks for the quick update, that worked!
badabingbreda
ParticipantThat does seem to work for now, thanks.
badabingbreda
ParticipantI think you meant to say MB AIO v.1.11.14
badabingbreda
ParticipantOkay, so maybe one or two more things:
You've been very helpful with other extensions already so maybe you are willing to a add two action hooks, one for
MBR_Relationship::add()and one forMBR_Relationship::delete()?I see a situation that one might want to update a custom field to keep track of the total number of relations for a relationship id. Because changes can me made from both ends an action might be a better fit to do that once, so that it can easily be displayed without the constant overhead of counting the rows in
wp_mb_relationshipstable at runtime.Another use for it would be to clear the cache on the post for which the relation has just been added or deleted. I don't think that's currently possible, since it doesn't keep track of changes.
badabingbreda
ParticipantOkay, so thanks Anh for helping me out. I made this into a plugin available for download.
Needs Meta Box and MB Relationships extension obviously; The plugin/field is NOT a replacement of the Relationships Field, but can be used to control multiple relationships like the one described in the repo's README.
badabingbreda
ParticipantLOL, if only you had chipped in earlier... It does seem to work! Thanks for that!
Great, now I can remove all my workarounds that do the important stuff that doesn't work when you don't register the metabox, namely adding, deleting and getting the connections... 🙂
Hopefully my last question:
Now that I have no use for the meta boxes but CAN use the relationships, is there a way to hide the meta boxes using a parameter while registering the relationship by any chance? I tried using the show/hide extension, targeting a input_value but to no avail. Currently writing CSS that echos with the field that hides them, but maybe there's already something for that.badabingbreda
ParticipantI continued on my quest to make it work. I managed to find a way to get most things to work as I wanted it, but I'm still hitting a bit of a snag.
Please review my video first to see that it works.
https://www.loom.com/share/57850d8cbe524626bcf4431f6f6dbc3fThe
MB_Relationship_API::register()command is there, but in order to make it stop registering it whenever I'm on admin and in the post_type 'attendance'. That way the metaboxes don't show up and don't save, thereby not interfering with my coded API::add() and API::delete()I do that by checking for
is_admin()andget_post_type( $_GET['post'] ) == 'attendance'in themb_relationships_initaction-hook. If both true, the script bails early, thereby not registering the relationships.However, it currently only works on a UPDATE-action on the post. On the initial CREATE of a new attendance-post it doesn't seem to work. My guess is that the relationship IS registered (doesn't bail early) and overwrites my coded relationships.
Any ideas to make this final piece of the puzzel? I have all the goodies from MB Relationships API, but need a way to block the relationships from overwriting my code when editing a post.
badabingbreda
ParticipantThanks for that video, but it illustrates exactly what is not supposed to happen. You were able to set John as both absent and present.
badabingbreda
ParticipantYes, I know that works. What I meant was that when you DUPLICATE an existing block it doesn't get a unique id.
In case you would have settings that generate some inline-css that style the block. You would need the block id to target it. The whole idea behind ids is that they should be unique.
-
AuthorPosts