Title: Timjwp's Replies | WordPress.org

---

# Timjwp

  [  ](https://wordpress.org/support/users/timjwp/)

 *   [Profile](https://wordpress.org/support/users/timjwp/)
 *   [Topics Started](https://wordpress.org/support/users/timjwp/topics/)
 *   [Replies Created](https://wordpress.org/support/users/timjwp/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/timjwp/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/timjwp/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/timjwp/engagements/)
 *   [Favorites](https://wordpress.org/support/users/timjwp/favorites/)

 Search replies:

## Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)

 *   Forum: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
   
   In reply to: [less css w/ multisite](https://wordpress.org/support/topic/less-css-w-multisite/)
 *  Thread Starter [Timjwp](https://wordpress.org/support/users/timjwp/)
 * (@timjwp)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/less-css-w-multisite/#post-3060013)
 * Thanks for the response Chris.
 * I’m not sure you are correct. All css and js files are loaded within the theme
   using get_template_directory_uri() but only the less file is throwing an error.
   I think it has something to do with how less is generated.
 * > The theme is using get_template_directory_uri(). To load the stylesheets which
   > should return the current sites domain as the base but they are loading from
   > the mainarray.com domain.
 * As stated this is multisite install. My other sites and themes on this install
   load styles, images etc. from mainarray.com (the domain which WordPress MU is
   installed on) without error.
 * > Also to note the wp-content directory has been changed to uzsources. Are you
   > following the Codex guidelines for moving wp-content?
 * The content directory was renamed using the Better WP Security plugin which has
   never been a problem before and again, if it were the cause, I would be seeing
   the error on other sites on the network. However, before I came here I did disable
   all my plugins just in case.
 * > You can fix this by adding the following line to your virtual host file
   > Header add Access-Control-Allow-Origin “[http://mainarray.com&#8221](http://mainarray.com&#8221);
   > 
   > Header add Access-Control-Allow-Origin “[http://tracesofviolet.com&#8221](http://tracesofviolet.com&#8221);
 * Shouldn’t this be avoided for security?
 * Thanks
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [admin-ajax from front end – hook not registered](https://wordpress.org/support/topic/admin-ajax-from-front-end-hook-not-registered/)
 *  Thread Starter [Timjwp](https://wordpress.org/support/users/timjwp/)
 * (@timjwp)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/admin-ajax-from-front-end-hook-not-registered/#post-2983625)
 * My function name was more specific I just used that here.
 * I have got it all working so and I really appreciate you hashing this out with
   me cause I’ve been working this out for a while now.
 * The problem was I had required my function.php when loading the form so all my
   functions were visible from there but I didn’t require it in my main plugin file
   so it wasn’t defined from within admin-ajax.php.
 * That coupled with the fact that my original ajax request (days ago) was incorrect
   and not thinking about the fact that the plugin might not be active because of
   errors just had me going down the wrong road.
 * Thanks again I do appreciate it!
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [admin-ajax from front end – hook not registered](https://wordpress.org/support/topic/admin-ajax-from-front-end-hook-not-registered/)
 *  Thread Starter [Timjwp](https://wordpress.org/support/users/timjwp/)
 * (@timjwp)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/admin-ajax-from-front-end-hook-not-registered/#post-2983621)
 * Something new to note.
 * I tried to use my plugin directory path ‘SWFEPATH’ defined in my plugin in admin-
   ajax.php defined as such;
 *     ```
       define('SWFEPATH', WP_PLUGIN_DIR."/".dirname( plugin_basename( __FILE__ ) ) );
   
       This returned an error.
   
       So I determined that the path definition (and subsequently the action hook) did not exist because my plugin had been deactivated at some point when it generated an error.
   
       So now the hook does exist and fires at the ajax request but the new problem is it doesn't see my callback function... ?
   
       My code in functions.php looks like this;
       ```
   
 * function edit_post(){
 *  // generate the response
 *  $my_post = array();
    $my_post[‘ID’] = $_POST[‘post_ID’]; $my_post[‘post_status’]
   = ‘publish’; $my_post[‘post_content’] = ‘This is the updated content.’;
 *  // Update the post into the database
    wp_update_post( $my_post );
 *  $response = json_encode( array( ‘success’ => true, ‘data’ => ‘Your job post 
   update was successful’ ) );
 *  // response output
    header( “Content-Type: application/json” ); echo $response;
   die(); }
 * add_action(‘wp_ajax_edit_post’, ‘edit_post’);`
 * and the error is;
 *     ```
       <br />
       <b>Warning</b>:  call_user_func_array() expects parameter 1 to be a valid callback, function 'edit_post' not found or invalid function name in <b>C:\xampp\htdocs\devsetup\wp-includes\plugin.php</b> on line <b>403</b><br />
       0
       ```
   
 * So it does not see my function.
 * Any thoughts on why that could be?
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [admin-ajax from front end – hook not registered](https://wordpress.org/support/topic/admin-ajax-from-front-end-hook-not-registered/)
 *  Thread Starter [Timjwp](https://wordpress.org/support/users/timjwp/)
 * (@timjwp)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/admin-ajax-from-front-end-hook-not-registered/#post-2983614)
 * Thanks for the advice.
 * I do know and implement WordPress development best practices. I am only editing
   core files on a dev setup for testing purposes to determine where the ajax is
   failing.
 * I’m using a child theme but the ajax posting from front end is being developed
   as a plugin not in the theme files (other than the form).
 * All your assumptions are correct.
 * Please keep in mind that the whole process works when I add the action hook and
   callback function inside admin-ajax.php. This means that the code I am using 
   is working. I have tested if the hook exists before adding it in admin-ajax.php
   and it doesn’t. So my hook is either not being registered for some reason or 
   it’s being removed before the ajax request is sent.
 * Here is the code in my js file.
 *     ```
       // JavaScript Document
       function ajaxSubmit(){
   
       	var formdata = jQuery(this).serialize();
       	formdata = formdata.replace(/%5B/g,'-').replace(/%5D/g,'');
       	formdata = 'action=edit_jobpost&'+ formdata + '&wpcf_action=cd_verify&security='+editpostnonce+'&_wpnonce='+wpnonce;
       	var update = jQuery(this).find('.wpcf-repetitive-response');
   
       	jQuery.ajax({
       		url: ajaxurl,
       		type: 'post',
       		dataType: 'json',
       		data: formdata,
       		beforeSend: function() {
       				jQuery('#wpcf-fields-under-title').hide();
                       jQuery('#wpcf-ajax-response').addClass('wpcf-ajax-loading');
                   },
       		success: function(data, textStatus, XMLHttpRequest) {
                   var id = '#feedback';
                   jQuery(id).html('');
                   jQuery(id).append('Your job post update was successful');
               },
        	});
       	return false;
       }
       ```
   
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [admin-ajax from front end – hook not registered](https://wordpress.org/support/topic/admin-ajax-from-front-end-hook-not-registered/)
 *  Thread Starter [Timjwp](https://wordpress.org/support/users/timjwp/)
 * (@timjwp)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/admin-ajax-from-front-end-hook-not-registered/#post-2983600)
 * Thanks for the quick response.
 * For testing I use both hooks but when live users will need to be logged in.
 * I am also localizing scripts though the hook I am using is add_action(‘wp_enqueue_scripts’,‘
   my_enqueue_function’). I’m fairly certain none of this is the problem.
 * Not sure if I was clear enough. I’m sure the ajax request is sent so that isn’t
   the problem. The problem is when the request reaches admin-ajax.php the hook 
   does not seem to be registered any longer. I have tested this using has_action()
   in admin-ajax.php
 * By adding the hook and call back function just before do_action() in admin-ajax.
   php I can determine that everything is processed without any errors so something
   must be removing my hook.
 * Let me know what info I can provide to help identify the problem.
 * Thanks again
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [New page template not showing – deactivate hack fail](https://wordpress.org/support/topic/new-page-template-not-showing-deactivate-hack-fail/)
 *  Thread Starter [Timjwp](https://wordpress.org/support/users/timjwp/)
 * (@timjwp)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/new-page-template-not-showing-deactivate-hack-fail/#post-2563865)
 * Problem was user error… DOH!
 * Was using dreamweaver for development and upload. Used filezilla to upload the
   templates to the other theme directories for testing.
 * Dreamweaver root directory was set to the parent of the domain root so files 
   uploaded from dreamweaver were not put in the necessary location.
 * I feel silly…

Viewing 6 replies - 1 through 6 (of 6 total)