Answers.Body: <p>There is also a pretty basic example here: <a href="https://github.com/CiviCooP/no.maf.oppgavexml" rel="nofollow">https://github.com/CiviCooP/no.maf.oppgavexml</a>
  This extension creates 2 files, introduces a page and a form. Might be able to give you some more understanding. But the real recommendation would be to take part in a CiviCRM developer training or CiviCRM sprint? Depending on where you are in the world you might be interested in a developer training in London that is coming up?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-18T07:05:20.953Z
Answers.LastActivityDate: 2015-08-18T07:05:20.953Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>To use a hook, you can:</p>
  
  <ul>
  <li>Write a CiviCRM extension.  This is the preferred method.</li>
  <li>Write a Drupal module.</li>
  <li>Write a Joomla or Wordpress plugin.</li>
  </ul>
  
  <p>The easiest way to write a CiviCRM extension is to install <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension">civix</a> and run <code>civix generate:module org.myorg.myextension</code>.  Then you can edit myextension.php and paste in that code.</p>
  
  <p>However, as that page says - this presumes that you have a basic knowledge of PHP, Unix, and object-oriented programming.  If that's not a skill you're going to learn today, and you want to cheat a little - take an existing extension and hack it!  Download an existing function, preferably one that does very little, and modify it to your needs.  I just uploaded an extension to Github that fits this need exactly <a href="https://github.com/PalanteJon/org.cpehn.module.contributionpagecustomizations">here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-18T05:41:32.877Z
Answers.Text: Thank you. Do I put that in  /var/www/drupal/sites/all/modules/civicrm_extensions and then inside a folder, in your case, namedcontributionpagecustomizations?
Answers.UserDisplayName: OregonJohn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-18T08:07:36.560Z
Answers.Text: Thank you. I got that to work, renaming your folder, php file names and I replaced your 'contributionpagecustomizations' with my 'formcustomization'  in the php files. Got it to install in 'Manage Extension' but --- if ($formName == 'CRM_Activity_Form_Activity' && $form->getaction() == CRM_Core_Action::ADD) {$form->setDefaults(array('assignee_contact_id' => $form->_currentUserId)); --- did not set the default assignee to current user. Any ideas? Thanks in advance.
Answers.UserDisplayName: OregonJohn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-18T08:11:07.110Z
Answers.Text: Got it. That did work, just had to refresh the page! Thank you, new horizons await me!!!
Answers.UserDisplayName: OregonJohn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-18T04:40:03.037Z
Answers.LastActivityDate: 2015-08-18T04:40:03.037Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I am excited to be working with civicrm, but I am quite frustrated at this point and so I hope someone can help me.</p>
  
  <p>I can see how valuable hooks are, and it seems like they are actually very basic to implement, but I need a small amount of pre-knowledge to use them.  I have read every link I could find about hooks to change forms and yet I find myself lost.</p>
  
  <p>I did find one example that fit my needs exactly, and would be a great learning experience ... but the description leaves out a lot of necessary information for someone as new as me.</p>
  
  <p>Can someone walk me though implementing this? It comes from <a href="https://civicrm.stackexchange.com/questions/4399/how-can-i-set-assigned-to-for-an-activity-to-default-to-the-logged-in-user-nam">How can I set “Assigned To” for an Activity to default</a></p>
  
  <p>The extension mentioned in the comment above is:</p>
  
  <p><code>function myextension_civicrm_buildForm($formName, &amp;$form) {
    if ($formName == 'CRM_Activity_Form_Activity' &amp;&amp; $form-&gt;action == CRM_Core_Action::ADD) {
      $form-&gt;setDefaults(array('assignee_contact_id' =&gt; $form-&gt;_currentUserId));
    }
  }</code></p>
  
  <ul>
  <li>How do I find the 'create activity' form this relates to?</li>
  </ul>
  
  <blockquote>
    <p>I got that answer myself -- <strong>CRM</strong> _ <strong>Activity</strong> _ <strong>Form</strong> _ <strong>Activity</strong>
    means the php file is in </p>
    
    <p>/var/www/drupal/sites/all/modules/civicrm/<strong>CRM</strong>/<strong>Activity</strong>/<strong>Form</strong>
    and then <strong>activity.php</strong></p>
  </blockquote>
  
  <ul>
  <li>Do I copy the form to my /var/www/drupal/sites/all/modules/civicrm_extensions directory?</li>
  <li>Do I put that function inside the form I copied?</li>
  <li>Do I create that as a file?</li>
  <li>If a file, what do I name it?</li>
  <li>Where do I put the extension once I create it?</li>
  </ul>
  
  <p>You are all very helpful and I appreciate it. Thank you in advance for any help you can give me on this problem I face.</p>
  
  <p>Just a note about searching for answers: About a month or two ago I found a web page that explained some of this to me but for the life of me I fail to find that page today. I did find a lot of links that looked like they could help but a whole mess of them led to (Page Not Found) on <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/" rel="nofollow noreferrer">http://wiki.civicrm.org/confluence/display/CRMDOC/</a>. Seems a lot of pages were deleted or renamed.</p>
  
  <p>Thanks again.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-18T12:47:58.310Z
Comments.Text: Note that the example code from that answer has just been updated to fix an error. You might want to change your hook code as well.
Comments.UserDisplayName: Coleman
Tags: <extension><activities><hooks>
Title: Using hooks -- simple please
ThreadText: # Using hooks -- simple please
  
  (Asked by: username_0 on 2015-08-18)
  
  I am excited to be working with civicrm, but I am quite frustrated at this point and so I hope someone can help me.
  
  I can see how valuable hooks are, and it seems like they are actually very basic to implement, but I need a small amount of pre-knowledge to use them. I have read every link I could find about hooks to change forms and yet I find myself lost.
  
  I did find one example that fit my needs exactly, and would be a great learning experience ... but the description leaves out a lot of necessary information for someone as new as me.
  
  Can someone walk me though implementing this? It comes from [How can I set “Assigned To” for an Activity to default](https://civicrm.stackexchange.com/questions/4399/how-can-i-set-assigned-to-for-an-activity-to-default-to-the-logged-in-user-nam)
  
  The extension mentioned in the comment above is:
  
  `function myextension_civicrm_buildForm($formName, &$form) {
  if ($formName == 'CRM_Activity_Form_Activity' && $form->action == CRM_Core_Action::ADD) {
  $form->setDefaults(array('assignee_contact_id' => $form->_currentUserId));
  }
  }`
  
  * How do I find the 'create activity' form this relates to?
  
  > I got that answer myself -- **CRM** \_ **Activity** \_ **Form** \_ **Activity**
  > means the php file is in
  >
  > /var/www/drupal/sites/all/modules/civicrm/**CRM**/**Activity**/**Form**
  > and then **activity.php**
  
  * Do I copy the form to my /var/www/drupal/sites/all/modules/civicrm\_extensions directory?
  * Do I put that function inside the form I copied?
  * Do I create that as a file?
  * If a file, what do I name it?
  * Where do I put the extension once I create it?
  
  You are all very helpful and I appreciate it. Thank you in advance for any help you can give me on this problem I face.
  
  Just a note about searching for answers: About a month or two ago I found a web page that explained some of this to me but for the life of me I fail to find that page today. I did find a lot of links that looked like they could help but a whole mess of them led to (Page Not Found) on <http://wiki.civicrm.org/confluence/display/CRMDOC/>. Seems a lot of pages were deleted or renamed.
  
  Thanks again.
  
  **Tags:** extension, activities, hooks
  
  > **Comments:**
  > **username_1**: Note that the example code from that answer has just been updated to fix an error. You might want to change your hook code as well.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2015-08-18. Score: 5 | Accepted answer
  
  To use a hook, you can:
  
  * Write a CiviCRM extension. This is the preferred method.
  * Write a Drupal module.
  * Write a Joomla or Wordpress plugin.
  
  The easiest way to write a CiviCRM extension is to install [civix](http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension) and run `civix generate:module org.myorg.myextension`. Then you can edit myextension.php and paste in that code.
  
  However, as that page says - this presumes that you have a basic knowledge of PHP, Unix, and object-oriented programming. If that's not a skill you're going to learn today, and you want to cheat a little - take an existing extension and hack it! Download an existing function, preferably one that does very little, and modify it to your needs. I just uploaded an extension to Github that fits this need exactly [here](https://github.com/PalanteJon/org.cpehn.module.contributionpagecustomizations).
  
  > **Comments:**
  > **username_0**: Thank you. Do I put that in  /var/www/drupal/sites/all/modules/civicrm_extensions and then inside a folder, in your case, namedcontributionpagecustomizations?  
  > **username_0**: Thank you. I got that to work, renaming your folder, php file names and I replaced your 'contributionpagecustomizations' with my 'formcustomization'  in the php files. Got it to install in 'Manage Extension' but --- if ($formName == 'CRM_Activity_Form_Activity' && $form->getaction() == CRM_Core_Action::ADD) {$form->setDefaults(array('assignee_contact_id' => $form->_currentUserId)); --- did not set the default assignee to current user. Any ideas? Thanks in advance.  
  > **username_0**: Got it. That did work, just had to refresh the page! Thank you, new horizons await me!!!  
  
  ---
  
  ### Answer by username_2 on 2015-08-18. Score: 2
  
  There is also a pretty basic example here: <https://github.com/username_2/no.maf.oppgavexml>
  This extension creates 2 files, introduces a page and a form. Might be able to give you some more understanding. But the real recommendation would be to take part in a CiviCRM developer training or CiviCRM sprint? Depending on where you are in the world you might be interested in a developer training in London that is coming up?
  
  
  ---
  
  