pandglobal
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Ajax call not working for my custom pluginThe ajaxurl is simply your endpoint to execute your PHP code. What is returned is whatever your code returns. That’s why I said
I have tested wp_send_json() and is not working, am using the latest version of wordpress and have only woocommerce and contact form 7 installed.
Is not working, it outputs errors in the console
$response = array('type' => 'match', 'message' => 'my test error message here'); wp_send_json($response)
yet is not working
Forum: Developing with WordPress
In reply to: Ajax call not working for my custom plugini found my problems, so i tested
var data = JSON.parse(‘{ “paul”: “my message content” }’);
alert(data.paul);and it worked, but thats just a manually inputted text in the js file.
So i want to ask if ajaxurl or adminajax in wordpress returns Json or Object?
and if it returns object how should i declare a variable with it
Forum: Developing with WordPress
In reply to: Ajax call not working for my custom pluginWhat is the AJAX needed for then
ajax is needed to do the following.
1. send the otp code to a server for confirmation and once confirmed it returns true.
2. then once is true, the main form will be submitted using $(‘#submit_button’).submit()
so the form am building is an otp modal widow in jquery and is good enough the message values and validation runs in ajax with out reloading the page.
Is bigger than normal required field js validation, it has to run a php file to get values and then know Whetter to submit the main form or not.
Forum: Developing with WordPress
In reply to: Ajax call not working for my custom pluginI really need help in step one and step four, if you can help with better code approach to enqueue and use wp ajax in my plugin, and the a step four that will make a call to the ajax any time a page loads so that i can know if ajax is actually working, before i can then add conditions to it
Forum: Developing with WordPress
In reply to: Ajax call not working for my custom pluginchecking capabilities is not needed since the plugin is just for contact form, which is mostly at the frontend for every visitor of the site whether logged in or not.
Forum: Developing with WordPress
In reply to: Ajax call not working for my custom pluginif i use
if ( ! current_user_can( ‘manage_options’ ) ) {// what will i actually do here, should i enqueue based on user capability, but i want the ajax call available for both logged and not logged in users. why must i check their capability?
}Forum: Developing with WordPress
In reply to: Ajax call not working for my custom pluginis it okay to use
jQuery(document).ready(function($) {
$(document).ready(function(){
or use onlyjQuery(document).ready(function($) {
????
Forum: Developing with WordPress
In reply to: Ajax call not working for my custom pluginIn the enqueuing of the scripts, you have the ‘test_script’ twice.
I was thinking that by having test_script for the test.js and localizing it by test.js and enqueue both script at once.
or should i have given different handler for test.js, and then use something like this local_test_script for the wp_localize_script(‘local_test_script’,…..?
Forum: Developing with WordPress
In reply to: How to get current page idoh thanks alot, your response was helpful
Forum: Developing with WordPress
In reply to: How to get current page idthanks @bcworkz i was able to get the $wp_query data using parse_query action and i can echo current page id using
this is the exact code i used
~~~
add_action(‘parse_query’, ‘showid’);
function showid(){
global $wp_query;$theid = !empty($wp_query->queried_object->ID) ? $wp_query->queried_object->ID : ”;
echo $theid;
}~~~
the problem there is that if i use echo $theid in the function above it shows the page id but if i use return $theid in the function it won’t show anything.
even if i do
~~~
$my = showid();
echo $my;
~~~it still don’t show. only works when i use echo but i don’t want it printing out on any pages i just want to use the value and echo it any time i wish to.
Forum: Developing with WordPress
In reply to: How to get current page idi have tried all i saw in the link you quoted above but none is working.
get_the_ID() throws undefined function, $wp_query is empty.suppose i want to loop or do anything what should i do?
Forum: Developing with WordPress
In reply to: Using wp media library with formsI found the solution using jquery.
Thanks.@sterndata i have looked into their source code and can’t get anything clear there, so all i ask is a simple hook filters and actions to add my own custom validation process inside that of wordpress validation for login
Forum: Developing with WordPress
In reply to: Listing all users through shortcodethanks alot @sterndata i appreciate your time and useful contributions
Forum: Developing with WordPress
In reply to: Listing all users through shortcodemy own tables, the whole idea was to create a user transaction history log.
so once the user submits the form it inserts some values into the database, i have that code working, and my problem with the above code which was meant to print out users transactions from the custom data table i created.
the code only returns details of the last user, not even the entire users is returned. if i can add custom column inside users table, how can i print it based on specific user?