Answers.Body: <p>Add following line before <code>add_filter</code> function:</p>
  
  <p><code>require_once(ABSPATH . 'wp-includes/pluggable.php');</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-08-06T03:32:22.493Z
Answers.Text: Oh my gosh, you are a genius! I have been pulling out hair all night trying to figure out how get my wordpress plugin to work with the civi hooks!
Answers.UserDisplayName: jsherk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-29T02:32:27.397Z
Answers.LastActivityDate: 2018-09-29T02:32:27.397Z
Answers.UserDisplayName: Hassan Farooq
Body: <p>When I try to edit my profile fields from my own contact dashboard as seen in the two images attached and click save, It does not seem to invoke civicrm_post hook in WordPress instance.
  <a href="https://i.sstatic.net/0N7B9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0N7B9.png" alt="enter image description here"></a></p>
  
  <pre><code>add_filter( 'civicrm_post', 'alter_profiles_event', 10, 4  );
  
  function alter_profiles_event($op, $objectName, $objectId, &amp;$objectRef){
     if ($objectName == 'Profile'){
      print_r($op);
      print_r($objectRef);
      die('ed');
      //does not enter here.
     }
  }
  </code></pre>
  
  <p><br>
  How can I make sure the hook is invoked?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-17T21:14:30.263Z
Comments.Text: I'd be surprised if `civicrm_post` didn't fire at all. Have you traced without testing for `$objectName`?
Comments.UserDisplayName: Christian Wach
Tags: <wordpress><contact-view>
Title: When editing my own profile visible under my contact dashboard, it does not enter CiviCRM "civicrm_post"API hook?
ThreadText: # When editing my own profile visible under my contact dashboard, it does not enter CiviCRM "civicrm_post"API hook?
  
  (Asked by: username_0 on 2018-09-17)
  
  When I try to edit my profile fields from my own contact dashboard as seen in the two images attached and click save, It does not seem to invoke civicrm_post hook in WordPress instance.
  
  add_filter( 'civicrm_post', 'alter_profiles_event', 10, 4  );
  
  function alter_profiles_event($op, $objectName, $objectId, &$objectRef){
     if ($objectName == 'Profile'){
      print_r($op);
      print_r($objectRef);
      die('ed');
      //does not enter here.
     }
  }
  
  
  How can I make sure the hook is invoked?
  
  **Tags:** wordpress, contact-view
  
  > **Comments:**
  > **username_1**: I'd be surprised if `civicrm_post` didn't fire at all. Have you traced without testing for `$objectName`?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-09-29. Score: 1
  
  Add following line before `add_filter` function:
  
  `require_once(ABSPATH . 'wp-includes/pluggable.php');`
  
  > **Comments:**
  > **username_3**: Oh my gosh, you are a genius! I have been pulling out hair all night trying to figure out how get my wordpress plugin to work with the civi hooks!  
  
  ---
  
  