janmoes
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Front end validation in step-formSo should I make like a switch, where I loop through all the inputs and check on the ID?
Also how in that loop with my current code, could I change it so that atleast one radio button per radio button group needs to be required?Forum: Developing with WordPress
In reply to: Front end validation in step-form@a2hostingrj I’ve seen and tried that way yeah.
In my example I just loop through all inputs. Which means it’s also going to loop through all
name="gender"radio’s for example. The validation works, but it prints it for example two times, because of this, while I only need one validation message.Forum: Developing with WordPress
In reply to: Ajax call not being able to return sent dataI was able to fix it. Normally I use jQuery, and I figured out, that jQuery sends data like something as FormData or URLSearchParams. So now I made an object filled with my fields and converted those in a URLSearchParams object!
Forum: Developing with WordPress
In reply to: Creating custom post type items with meta fieldsYeah I thought so too. If I register the Post Type in the activation hook, it would not exist after activating and refreshing the page. The content is being saved in the db, so that’s okay. But as I understand Init is a hook that runs on every request?
And which removal hook were you talking about?
Forum: Developing with WordPress
In reply to: Creating custom post type items with meta fieldsI managed to fix it like this:
register_activation_hook(__FILE__, 'activate_cpt_locations'); function activate_cpt_locations(){ $locations = [ [ 'post_title' => 'Amsterdam', 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'location', 'meta_input' => [ '_location_id' => 13529, '_sportivity_api_key' => 123456, '_clubplanner_username' => 'user', '_clubplanner_password' => 'pass', ], ], [ 'post_title' => 'Delft', 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'location', 'meta_input' => [ '_location_id' => 13529, '_sportivity_api_key' => 123456, '_clubplanner_username' => 'user', '_clubplanner_password' => 'pass', ], ], ]; foreach($locations as $location){ wp_insert_post($location); } } register_deactivation_hook(__FILE__, 'deactivate_cpt_locations'); function deactivate_cpt_locations(){ $locations = get_posts(['post_type'=>'location','numberposts'=>-1]); foreach ($locations as $location) { wp_delete_post( $location->ID, true ); } } add_action('init', 'register_location_cpt'); function register_location_cpt(){ $labels = array( 'name' => 'Location', 'singular_name' => 'Location', 'add_new' => 'Add New Location', 'add_new_item' => 'Add New Location', 'edit_item' => 'Edit Location', 'new_item' => 'New Location', 'all_items' => 'All Locations', 'view_item' => 'View Location', 'search_items' => 'Search Locations', 'not_found' => 'No Locations Found', 'not_found_in_trash' => 'No Locations found in Trash', 'parent_item_colon' => '', 'menu_name' => 'Location', ); //register post type register_post_type( 'Location', array( 'labels' => $labels, 'has_archive' => true, 'public' => true, 'supports' => array( 'title', 'thumbnail','page-attributes'), 'taxonomies' => array( 'post_tag', 'category' ), 'exclude_from_search' => false, 'capability_type' => 'post', 'rewrite' => array( 'slug' => 'locations' ), ) ); }Is it correct that the locations are inserted in the activation hook? And that the post type is made in the init hook?
Forum: Developing with WordPress
In reply to: API GET Requestshouldn’t I loop through $email[‘CustomerResources’] since I convert the object as an array?
Forum: Fixing WordPress
In reply to: Error when activating my own pluginAh okay, cool!
Do you have an example?Forum: Fixing WordPress
In reply to: Error when activating my own pluginWhat kind of table from wordpress standards would you prefer?
Forum: Fixing WordPress
In reply to: Error when activating my own pluginIt’s for an api, for the rest it has nothing to do with WP. So that’s probably why I did it that way.
Forum: Fixing WordPress
In reply to: Multiple AJAX calls in one formManaged to fix it. Apparently you don’t need a form to perfom an ajax request. as long as you send an action with the request which has the same name as the action in your php file!
Forum: Fixing WordPress
In reply to: Error when activating my own pluginOh that
<code>part somehow happened when posting this issue.
Otherwise, if that’s not what you mean. I’m wondering how else you can generate a table.
I would like to learn some more about it too! 🙂- This reply was modified 4 years, 7 months ago by janmoes.
Forum: Developing with WordPress
In reply to: Autoloading classesYeah my dumb fault, it was a long day and I was tired. I literally forgot a ‘.’ in front of
'class.php'to get classes likelocation.class.phpForum: Fixing WordPress
In reply to: Error when activating my own pluginI made my own custom plugin, and need to generate a table for api results.
Is there an other way besides installing a plugin for it or so?Forum: Developing with WordPress
In reply to: Rendering a php/html page with dataYeah I actually thought about. In the backend you either return the success message like “Your form has been submitted” or the list of errors. This can be done with some simple PHP logic, to let the system know what you want to return. And ofcourse what you said. Using the error/catch for server errors like a 4xx.
Forum: Developing with WordPress
In reply to: Rendering a php/html page with dataDidn’t know about that wp_send_json method :), I started working on developing plugins a week ago. But I already made the serverside validation. I’d like to learn how to imply that with my jquery/ajax code for future purposes etc.
With not finding a good example with my needs, I meant that a lot of small tutorials all look so different.
I was trying to find a tutorial where they could send like an entire $errors array to the catch/error method of an ajax request.