3

I've been reading the code of the plugin "Easy Digital Downloads" in order to learn more about plugin development techniques. I'm getting crazy because of a hook I can't manage to find where is being defined.

add_action( 'edd_edit_user_profile', 'edd_process_profile_editor_updates' );

Located in: includes/shortcodes.php Line: 918

I know edd_process_profile_editor_updates is the function used to process the profile updates (duh, obvious), and edd_edit_user_profile is the hook location that triggers the function, but I haven't been able to find where is being defined do_action('edd_edit_user_profile')

Yes, I did a full search for edd_edit_user_profile in the whole plugin but this is the only line that mention this hook.

Thanks in advance!

  • 2
    sometimes the prefix or the actions are variables, like PREFIX.'_edit_user_profile' or "edd_{$action}_{$current_screen}". try doing a folder contents search for do_action instead and see if what you're after is in there. if all else fails contact the author. – David Sword Mar 30 '18 at 4:59
  • a way of finding the call path is to call this function in edd_process_profile_editor_updates : secure.php.net/manual/en/function.debug-print-backtrace.php – mmm Mar 30 '18 at 5:54
  • Hi @mmm I think you rejected my edit on David Sword answer by mistake. Your rejection reason says: the code is a quote of existing code in the plugin then it must remain in this state even if the code is not optimised. but I'm not modifying the the plugin code, I'm just referencing the correct function because the one in the original answer its not the one used for my specific question and this may lead to confusion. – Luis Rivera Mar 30 '18 at 6:41
2

in

includes/actions.php

there's

function edd_post_actions() {
    $key = ! empty( $_POST['edd_action'] ) ? sanitize_key( $_POST['edd_action'] ) : false;
    if ( ! empty( $key ) ) {
        do_action( "edd_{$key}", $_POST );
    }
}
add_action( 'init', 'edd_post_actions' );

in

templates/shortcode-profile-editor.php

there's

..input type="hidden" name="edd_action" value="edit_user_profile" ..

which, if the two are used together, would make

do_action( 'edd_edit_user_profile', $_POST );

As I said in my comment on your post - its very common in WP for actions to be dynamic, so you need to be less specific on your search, exempting the prefix, variable actions, or just remove the key and search a large do_action query instead.

|improve this answer|||||
  • Great! This is exactly why I like to learn this way. This is the kind of techniques you don't normally get in tutorials. I totally see the potencial. – Luis Rivera Mar 30 '18 at 5:49
  • 1
    David, I'll fix your answer. The function defining the hook for my specific question is in includes/actions.php, technically is the same but lets fix this , one looks for edd-action which is for admin-actions, the other looks for edd_action which is for front-end actions. – Luis Rivera Mar 30 '18 at 6:10
  • 1
    Nice answer! Here's a little regex that will limit search results for do_action() to those using a dynamic string: do_action\((.*)[.|{] I use grep for searching within files. – Dave Romsey Mar 30 '18 at 6:34
  • I definitely need to learn regular expressions asap – Luis Rivera Mar 30 '18 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.