Why plugin ajax response is -1?

according to wordPress jedi, scribu, you can now enqueue scripts from inside the plugin handler. http://scribu.net/wordpress/conditional-script-loading-revisited.html you were echoing things and in shortcode handling you have to return. i ran into some issues getting the script to work by returning the script, so i moved it to an external file which definitely works. function myajax(){ … Read more

Buddypress: Load Ajax Without Template Pack [closed]

This is how I have used the default BP ajax queries/scripts in a custom BuddyPress theme: (gist with code: https://gist.github.com/3154297 ) function bp_custom_include_ajax() { global $bp; require_once( BP_PLUGIN_DIR . ‘/bp-themes/bp-default/_inc/ajax.php’ ); if ( !is_admin() ) { // Register buttons for the relevant component templates // Messages button if ( bp_is_active( ‘messages’ ) ) add_action( ‘bp_member_header_actions’, … Read more

wp_verify_nonce not working

I don’t know I just submitted the ticket on track. I was using get_current_user_id() and it modifies the wp_create_nonce behavior. Sinces wp_create_nonce uses wp_get_current_user() I think there is the problem.

WordPress Ajax Problems

You have nothing specific to do to “load” modified php code in WordPress. All files are just loaded as is at execution time (ie when the HTTP request is processed by the server). You just have to verify that your plugin is active. Your curl command is malformed. Use this instead : curl -X POST … Read more

Stumped – Ajax Response Returns 0

Debug it logically. This code works. I just tested it. This in a theme (I put it in header.php for testing): jQuery(document).ready(function() { var lanid = ‘demo’; var ajaxurl=”<?php echo admin_url(“admin-ajax.php”, null); ?>”; data = { action: “get_ldapattr”, lanid: lanid}; jQuery.ajax({ url: ajaxurl, data: data, dataType: ‘json’, type: ‘post’, success: function(response) { console.log(response); } }); … Read more

Why is this Ajax not working?

When you load a php file directly via an ajax request (UncheckPackageThemeHelper.php) it’s loaded outside the context of WordPress, so no WordPress core functions are available. All WordPress ajax requests should be routed through admin-ajax.php. You can print the URL with the function admin_url: admin_url( ‘admin-ajax.php’ ) When admin-ajax.php is loaded, WordPress is bootstrapped, so … Read more

wp_insert_comment and security

wp_insert_comment() is low level function, it only saves passed data without concern for what it contains. If you are looking to replicate sanitizing WP does on comment data (totally good idea 🙂 you are probably looking for higher level wp_new_comment().

Accept AJAX call with serialized form data

When working with AJAX and Forms in WordPress I like to code in the ajax action to the form so serialize works out of the box. Actually I wrote an article on this last year: https://webdevstudios.com/2015/02/12/handling-ajax-in-wordpress/ But, you’re here for answers, not a blog article, so here’s the brief part of it. You have three … Read more

Help with AJAX front end comment moderation

Seems to me that the only problem is that you put the full approve url in the link, in this ways when you click the link you trigger the ajax and open the page url in the link. To be more clear your link is something like: <a class=”p3-comment-moderation” href=”https://wordpress.stackexchange.com/questions/128383/admin-ajax.php?action=p3_comment_approve&comment_id=123&nonce=xxxxx” data-comment_id=”123″ data-nonce=”xxxxx”>Approve</a> thanks to the … Read more