if(is_admin()){
add_action( 'wp_ajax_validate_form', 'validate_form_ajax_callback' );
add_action( 'wp_ajax_nopriv_validate_form', 'validate_form_ajax_callback' ); // need this to serve non logged in users
add_action( 'wp_ajax_validate_profile', 'validate_profile_ajax_callback' );
add_action( 'wp_ajax_nopriv_validate_profile', 'validate_profile_ajax_callback' ); // need this to serve non logged in users
}
function validate_form_ajax_callback(){
if(isset($_POST['verify-transaction']) && wp_verify_nonce($_POST['verify-transaction'], 'wp-verify-transaction')){
wp_die('{"response":"ok","msg":"Form Submitted"}');
}else{
wp_die('{"response":"error","msg":"Unknown source"}');
}
}
function validate_profile_ajax_callback(){
if(isset($_POST['profile-information']) && wp_verify_nonce($_POST['profile-information'], 'wp-profile-information')){
wp_die('{"response":"ok","msg":"Profile Submitted"}');
}else{
wp_die('{"response":"error","msg":"Unknown source"}');
}
}
// Generate form page
function generate_store_form_page(){
// ENQUEUE and LOCALIZE SCRIPTS
wp_enqueue_script( 'my-ajax-handle', plugin_dir_url( __FILE__ ) . 'store.js', array( 'jquery' ) );
wp_localize_script( 'my-ajax-handle', 'the_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
include_once 'form.php';
}
add_shortcode('store_form_page', 'generate_store_form_page');
As per, https://codex.www.ads-software.com/AJAX_in_Plugins, I have placed the add_action calls inside if(is_admin()){}
This code works perfectly for admin, but breaks for any other role. All that happens is that the ajax is returned the homepage. It’s almost as if it’s no ajax registration is taking place. I removed the ‘if(is_admin()){}’ and that did not help. I’ve seen multiple threads about this, but none I find have actual resolutions. Any help would be appreciated.
]]>I have the following setting:
Ajax container ID:* content
Menu container class:* header
Search form TAG ID:* search
Thank you for your support!
https://www.ads-software.com/plugins/ajaxify-wordpress-site/
]]>Some of my photos do show and half do not (in my older posts). I have tried the AJAX Thumbnail Rebuild which helped a bit but didn’t solve the whole problem. I’ve tried the plug-in once more and it stayed the same.
Should I be changing some code in my header.php or functions.php?
Thanks for any help- I’m about to pull out my hair!
Here is the link to my blog curiousmeredith
And here is a link to a post that is experiencing problems.
https://www.ads-software.com/extend/plugins/post-thumbnails/
]]>If any one has got idea about such plugins then please share it.
]]>Ideally, the permalink would look more like this: https://www.mydomain.com/#name-of-post-or-page/
Does anyone either know how to change the permalink structure in the ‘Ajax for All’ plugin -OR- know of another plugin that works with WP 3+?
Thanks!
]]>I am trying to utilize ajax-functionality for a plugin I am creating, but get a 500 Internal Server Error when trying to do so. Here is what I am doing:
However, step 5 fails, and only the backfire of ajax_callback is printed. The jQuery.Post call looks like this:
$.post(ajaxurl, {
action: "ajax_callback",
caseType: "1",
data: array1
}, function(data) {
$("#result").html(data);
}, "text");
And the axax_callback looks like this:
add_action('wp_ajax_ajax_callback', 'ajax_callback');
function ajax_callback() {
if (!$_POST['caseType']) {exit("caseType is not defined");}
switch ($_POST['caseType']) {
case "1":
$data = $_POST['data'];
print_r($data);
break;
case "2":
$data = $_POST['data'];
print_r($data);
break;
}
So basically, ‘caseType’ defines what to do, and ‘data’ is passed on. But why am I getting the backfire from saying “caseType is not defined”? As seen by the JavaScript code, case “1” of the ajax_callback should be invoked, and the ‘data’ printed directly.
Any ideas on what is going wrong?
]]>Thanks!
]]>