Forum Replies Created
-
AuthorPosts
-
September 27, 2022 at 6:32 AM in reply to: Second validation message with rwmb_frontend_after_display_confirmation #38432
Graceson
ParticipantHi Long,
Thank you for this additional idea. Is there a way to add the message without throwing the validation error?
If I use this example, my code will likely end up looking something like this (untested sudo-code):
add_filter( 'rwmb_frontend_validate', function( $validate, $config ) { if ( !empty( $_POST['subscribe_to_newsletter'] ) ) { add_email_to_Mailchimp(); if ( add_email_to_Mailchimp() == 'error') { $validate .= "<div class=\"rwmb-error\">Unfortunately, your newsletter subscription failed. </div>"; } } return $validate; }, 10, 2 );However, this means that validation for the form submission will depend on the Mailchimp API response as handled by my
add_email_to_Mailchimp();function. I do not want that behavior.I want the form to be able to submit, but to also display an additional message to tell the user whether or not they were successfully subscribed after I have a chance to process all the data and transmit information to Mailchimp.
September 23, 2022 at 7:23 AM in reply to: Second validation message with rwmb_frontend_after_display_confirmation #38398Graceson
ParticipantI also thought that I'd add that I tried some other options as tests. My hunch is that
rwmb_frontend_after_display_confirmationruns beforerwmb_frontend_after_processand that is why nesting the hooks as I did above does not work.However, I tried other options that also do not work. For example this code does not output another message as desired:
add_filter( 'rwmb_frontend_validate', function( $validate, $config ) { add_action( 'rwmb_frontend_after_display_confirmation', function( $config ) { echo "<div class=\"rwmb-error\">Unfortunately, your newsletter subscription failed.</div>"; }, 9, 1 ); return $validate; }, 10, 2 );I'm kind of at a loss of what else to try. I have yet to figure out any way to dynamically add a message depending on what the user submitted.
September 23, 2022 at 3:16 AM in reply to: ✅rwmb_frontend_after_display_confirmation filter not working with AJAX shortcode #38396Graceson
ParticipantHi Long,
Do you have an update as to when this will be fixed?
Thanks!
September 23, 2022 at 12:11 AM in reply to: Ajax interfering with using get_the_ID() inside rwmb_frontend_after_process #38395Graceson
ParticipantHi Long,
I don't think this answer quite gets at the problem I was having (which is still unsolved).
What I was trying to say is this. When ajax is turned on, the following no longer works:
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) { $reference_post_ID = get_queried_object_id(); $data = [ 'reference_post_ID' => $reference_post_ID, 'field_2' => 'value 2', 'field 3' => ['one', 'two', 'three'], ]; \MetaBox\CustomTable\API::update( $post_id, 'my-custom-table', $data ); }, 10, 2 );The idea is that I want to save the ID of the current post where the form is displayed to the post that is being submitted by the user. That way, I can track which post each submission came from. This works with
[mb_frontend_form id="field-group-id" ajax="false"]but it fails when[mb_frontend_form id="field-group-id" ajax="true"]Thanks,
GracesonGraceson
ParticipantThanks Long! I think that filter was something I had seen at one point, but I couldn't find it again. I'll give that a shot, and otherwise your second solution seems very straight forward.
August 31, 2022 at 6:40 AM in reply to: ✅Custom Table Values - Not Saving To The Custom Tables #38136Graceson
ParticipantI believe that I am also affected by this bug. Since updating Meta Box AIO, my custom fields saving to a custom table no longer work.
Please let us know when a fix is available. Also, can you also give us a way to rollback extensions/AIO? I think it would save people a lot of time when trying to diagnose stuff like this. See https://support.metabox.io/topic/how-to-access-older-versions-of-extensions/.
I have now rolled back to the last version of AIO that I manually downloaded, which appears to work for now.
Graceson
ParticipantI completely agree! We need the option to rollback to previous versions. Otherwise, we can't effectively troubleshoot issues. That just makes everyone's lives worse.
Graceson
ParticipantHi Long,
I had forgotten that MB can do that, so thanks for pointing it out! However, what I think would be nice is a solution that is a bit more complete.
Because phone numbers around the world have different formatting systems, it would be really nice to have a field that is more flexible. That is why I propose a field that has a built-in drop-down for selecting the proper country code. Once the user has selected the code for their country, the form could automatically use the proper format validation for that country’s phone number format.
Is this something that could be done?
February 2, 2022 at 11:57 PM in reply to: Is it possible to use URL Query Strings in Frontend Submissions to populate CFs? #33627Graceson
ParticipantGreat! If you end up getting a working solution it might be nice to post some example code to help the next person who comes along.
Also, in that vein, here is the link to the documentation for the hidden field type in case anyone needs it. I forgot to include it in my original response.
https://docs.metabox.io/fields/hidden/.
Here is a result I got for googling how to get strings out of URLs using PHP. Looks like there are a couple of helpful functions to do this sort of thing that can be put together. Depending on the info you are trying to collect, you may not even need Regex, which would be nice.
https://stackoverflow.com/questions/13907793/preg-match-need-to-get-a-string-out-of-an-url
In case you end up having to use Regex, here are some helpful cheat sheets for learning the syntax:
https://www3.ntu.edu.sg/home/ehchua/programming/howto/Regexe.html
https://www.keycdn.com/support/regex-cheatsheetFebruary 2, 2022 at 4:57 AM in reply to: Is it possible to use URL Query Strings in Frontend Submissions to populate CFs? #33601Graceson
ParticipantNote: I think of myself as an advanced googler rather than an actual dev. I'm also not familiar with the features in those other products mentioned, so my apologies if I have misunderstood what you want to do.
However, I'm currently working on a project where I am saving custom info into hidden fields, which might be similar to what you want to do.
Currently, I am making some hidden custom fields in MB. They don't show up in the frontend, but I can save whatever type of data I need to them by hooking into
rwmb_frontend_after_process(currently I am using MB custom table to store everything). Then, it is just a matter of getting the data you want to save. I imagine that you can write some regex type code in some php functions to get strings out of the url to populate the fields. There might be more clever ways, but that is where stack overflow can come in handy.Hopefully that gives you a sense of one route to do this type of thing.
Graceson
ParticipantHi Long,
Thanks for highlighting that link again. I had tried everything except switching themes, and looks like that is where the issue was coming from. I will take this up with the authors of my theme.February 5, 2021 at 12:42 AM in reply to: ✅Creating a Citation Insert Plugin that Uses Shortcodes to Generate List of CTPs #24329Graceson
ParticipantSo I have now had a chance to try test out building this shortcode. I decided to try using php in a custom plugin so that I could give the shortcode my own name. However, I can't figure out how to solve a couple problems.
I am planning on having the shortcode look as follows [ref pub_id=399], where pub_id is the post ID for the publication post that I am trying to cite.
The first issue I am having is that I would like the shortcode to return a number every time it is called. The first instance should return 1, the second time it should return 2, and so on. However, if the same publication post is called multiple times, I would like all of those shortcodes to return the same value.
The second issue that I can't figure out is how to output my reference list at the end of the page. My goal is that at the end of the_content WordPress will automatically insert a numbered list of all the publications I am trying to cite. I think I know how to do this, if I can only figure out a good way to determining all of the instances of the shortcode used on the page and what order they were used in.
My initial though of how to handle these two issues was to write the shortcode function to set up an array and then add the pub_id value to that array each time the shortcode is used. I would then use that array in another function hooked to the_content. I tried using a global variable to do this, but I can't seem to get the values to be passed. After some research, it looks like shortcodes are only meant to return strings, and global variables are discouraged.
The next thing idea I had was to write a function that looks for all of the times the shortcode has been used in the_content and then use that information to append the citations into the-content. I found this question which seems very related: https://stackoverflow.com/questions/56627970/wordpress-get-all-shortcodes-from-content-field. I haven't tried this method yet, but it should probably work for creating the citation list at the end of the post. The issue then becomes, how do I get the shortcode to return the proper numbers at each location as described above?
I am a php and wordpress beginner, so I think that what would be most helpful is to get suggestions on high-level approaches to getting the functionality I desire. Basically, the end goal is to get LaTeX-like citing functionality within WordPress. I haven't found any existing plugins that do this the way I would like, and so this shortcode approach seemed like a good idea to me, but maybe there is another option that I haven't considered at all.
February 2, 2021 at 5:06 AM in reply to: ✅Creating a Citation Insert Plugin that Uses Shortcodes to Generate List of CTPs #24288Graceson
ParticipantHi Long,
Thanks for those helpful links. I will give that a shot and report back once I have a better sense of how things work.
Thanks,
Graceson -
AuthorPosts