ajax response not recieving

As per jQuery documentation, dataType: ‘json’ is supported. That is the thing that is being returned and parsed by jQuery to your success function. There is more information needed to resolve your issue. Does pin_shop.ajax_url properly resolve to //site.com/wp-admin/admin-ajax.php? If not, there’s your first problem. (To check this, console.log(ajax_url); just before your $.ajax call. I … Read more

Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”

It’s working, I traced it by digging through admin-ajax.php to see what was responding with 401/400. My fix was basically making the action parameter the last thing appended to the formData formData.append(“enquiry”, form); formData.append(“action”, “enquiry”); I don’t normally use formData to post things, .serialize() has always been enough for me over the years. As I … Read more

Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin

Create custom actions with add_filter(post_action_{$action}); Even if it’s just to test, editing core files is bad practice. I prefer to download the source code onto my own machine and find where and how the hooks are firing. Anyway, there is very poor documentation in this part of the source code, but I’ve been studying it … Read more

How can I add IP address to my post?

I’ve modified your code and moved $ip inside the function. That way the variable is easily accessible from the function itself. function cptpost() { if (!empty($_SERVER[“HTTP_CLIENT_IP”])) { $ip = $_SERVER[“HTTP_CLIENT_IP”]; } elseif (!empty($_SERVER[“HTTP_X_FORWARDED_FOR”])) { $ip = $_SERVER[“HTTP_X_FORWARDED_FOR”]; } else { $ip = $_SERVER[“REMOTE_ADDR”]; } $dateTime = date(“Y/m/d g:i:sa”) //create post object $userid = get_current_user_id(); $my_post … Read more

WordPress 5.4 – How to prevent to enter only certain values in custom field

You can make the meta data private, and not visible on the Custom Fields list, by appending underscore to the meta key. I.e. _accesstype_visibility You can find more details in the WP Developer docs, https://developer.wordpress.org/plugins/metadata/managing-post-metadata/#hidden-custom-fields EDIT 24.7.2020 Here’s an example how to use is_protected_meta() filter to make meta key public or private. You can read … Read more