I'm trying to write some plugins to incorporate PCPs (mainly lists of them) into my Wordpress sites. I did not see in the API explorer any coverage of PCPs. (I could be blind, please feel free to correct me.)

I'd like to build a search feature, so that a visitor could search by multiple variables, like pcp owner name, or contribution campaign, etc. I'm also thinking of listing top fundraisers for a campaign.

I think I could write something using mysql queries but was wondering if there is a better way to go about it.

1 Answer 1


PCPs don't have an API currently - but I just wrote one in about 15 minutes. I didn't write unit tests, so I can't submit it upstream - maybe this is something you can help with to make CiviCRM better?

Paste the contents of this file into "Pcp.php" in your civicrm/api/v3 folder: http://pastebin.com/cvzqfq69

There's some odd line of hyphens at the bottom, leave that off! Next, in civicrm/api/v3/util.php, you should see a part that looks like:

  // FIXME: DAO names should follow CamelCase convention
  if ($name == 'Im' || $name == 'Acl') {
    $name = strtoupper($name);

Change that "if" statement to:

  if ($name == 'Im' || $name == 'Acl' || $name == 'Pcp') {

That should get you a working PCP API!

  • Why not make a Pull Request for it.
    – Emeka Mbah
    Commented Mar 17, 2016 at 14:32
  • APIs aren't accepted without a unit test - and I literally made this API in response to this question! I can justify spending 15 minutes, but not several hours for writing tests. Commented Mar 17, 2016 at 14:40
  • its all about giving back to the community :)
    – Emeka Mbah
    Commented Mar 17, 2016 at 14:48
  • Agreed - but I spend several hours a week giving back to the community! In fact, I wrote both the StatusPreference and Soft Credit APIs as a volunteer. I have a running list of "community improvements", and unfortunately this isn't very near the top :) Commented Mar 17, 2016 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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