I am familiar with elementor forms new_record hook that I can work with and add some custom actions.
I am looking for a way to add some custom metadata to the save_to_database action elementor has, which saves the form submission in the DB. I have searched and have not found any specific hook that allows me to add custom metadata.
I would like to have on the new_record hook the submission id that was stored and then I can write my own query as needed.
Does anyone know of a way to get the submission id on this hook?
Thanks
Related
I have installed Linoor theme which contains a post type called 'Events'. I want to implement the Events submission form for admin as well as visitors. The plugin Events Manager provides this facility for visitors to submit their events with admin approval. However, the plugin doesn't override the post type created by the theme. Also, in the admin side the 'Events' post type as duplicated fields for Event Address, location, timings, etc.
Is there a way to disable or remvoe this post type? Or hide/remove/disable the fields while creating a new event?
I looked up the theme and plugin's documentation but couldn't find the prooper way to solve this.
you can use simply this code in functions.php
function remove_post_type(){
unregister_post_type( 'events' );
}
add_action('init','remove_post_type', 100);
You can use unregister_post_type with CPT's slug.
Reference:
https://wordpress.stackexchange.com/questions/3820/deregister-custom-post-types
Right now I am using the ultimate member plugin to register users. But the company asked me to change the form and allow users to insert their education qualifications in a table when registering. Users need to have a button that has the ability to insert more rows (If they have more qualifications).
As far as I know, I can't use the Ultimate Member plugin for that. I searched for many table plugins but didn't find anything that can do this task. I once had done this using code. But I don't know how to apply it to this registration form. If anyone can figure out a way to embed the code to Ultimate member (to save that table data) or any plugin that can do this, please let me know soon as possible.
Updated Question
I have tried that shortcode and got confused as it ruined the page. Now I'm trying a PHP method to solve this problem.
Thank You
Well you have many options to solve this problem. What you are actually looking for is Custom Fields.
WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as metadata.
Now, custom fields can be created in 2 ways.
Either you write php code in a plugin/theme
Or you you install plugin which helps you build custom fields.
What you are actually looking for is to create Repeatable Field Groups. These are the field which can be replicated. As many as you want.
Some plugins which provide facility to add them in no particular order are:
Advanced Custom Fields - Repeater Field : https://www.advancedcustomfields.com/resources/repeater/
Toolset - Repetable Field Group : https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/
Metabox - Meta Box Group : https://metabox.io/plugins/meta-box-group/
They all will give you ability to create repeater fields.
Repeater field can be made for both users and posts or Custom Post Types(CPT). You need them for Users. I am not sure which one of them allows you to create repeater field for Users but you can check on there website.
PS : These are all paid plugins. (They may have free version of them but repeater field comes with PRO).
Once you have created a field for users you can use that field in your registration form.
UPDATED ANSWER
As the question author wants to add the field using PHP, the field can be added as so.
After looking at all the hooks available to the user by UM (Ultimate Member) plugin. I found two hook that can be used to add fields and save in the backend.
um_after_form : Some actions after register form fields.
add_action( 'um_after_form', 'my_after_form', 10, 1 );
function my_after_form( $args ) {
// add your repetable fields here.
}
um_after_save_registration_details : Action on user registration after save details. This runs after the form is submited and user is registered. Use this to save data inside the user database.
add_action( 'um_after_save_registration_details', 'my_after_save_registration_details', 10, 2 );
function my_after_save_registration_details( $user_id, $submitted ) {
// Save field here.
// You have user_id and submitted data, do your thing here.
}
Some wordpress captcha plugin use login_form hook to add their fields. Is it possible to provide support for login_form hook in my plugin's custom form? It means if someone use this hook to add their work it will reflect on my custom plugin's form so that i can get befefit from this.
Please help me :(
Yes, it's possible. For example, through ACF form fields that are saved in the database and can used to fetched for another query through get_post_meta. Check this out: https://www.advancedcustomfields.com/resources/acf_form/.
I am attempting to create a front-end form for a template page and am using the following code. The code works allows the post to be submitted to the custom post type however, it allows the form to be submitted with no data in the fields. Also, I can't figure out how to get the redirect to work correctly.
http://pastebin.com/ts4dmW6A
I recommend to have the form handler inside functions.php or in a plugin rather than the template. If you use a hook you can then handle any form submissions there. Action field would determine which hook should be called.
More details can be found here:
https://codex.wordpress.org/Plugin_API/Action_Reference/admin_post_(action)
How can I validate WordPress custom fields without using Javascript. I want to validate them using PHP and stop post creation on error.
You can do that using the hook save_post. There are lots of examples in WordPress Answers, check the results for +save_post +update_post_meta is:answer.
If it doesn't validate, use wp_die() and the post won't be saved.