CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Display profile php call? Wordpress
Pages: [1]

Author Topic: Display profile php call? Wordpress  (Read 1413 times)

dtheweather9

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 1
    • Students for the Exploration and Development of Space, USA
  • CiviCRM version: 4.4.0
  • CMS version: WordPress 3.8.1
  • MySQL version: 5.1.56
  • PHP version: 5.4.11
Display profile php call? Wordpress
March 04, 2013, 08:26:48 am
Good Morning,

I'm playing around with putting together my first plugin, more or less to kludge together buddypress and civicrm in wordpress.  I don't particularly care about merging civicrm with the buddpress profile (the buddypress profile can remain the 'public' information, which isn't sync'd to anything but its own fields in buddypress, therefore not connected to civi), but I do want to have the user's profile on the edit field display the 'edit profile' of civicrm so they can customize their membership information there.  I've wrote a standard wordpress plugin thus far that will perform a php function placing things where I want them on the template, now I'm currently trying to figure out how to pull the profile into the page.

Is there a way to have a php function or something which would pull the form/profile which would be typically displayed on
<siteroot.org>/?page=CiviCRM&q=civicrm/profile/edit?reset=1&gid=N

where N is the profile id into the page? 
Would the function calls for this instead have to be a php as a module inside of civicrm, or could it be run as a wordpress plugin?

Also an another question on the profile (somewhat unrelated); If I had a view only profile,
<siteroot.org>/?page=CiviCRM&q=civicrm/profile/view?reset=1&gid=N&id=X

would adding $id=X where X is the civicrm contact id allow me to have users view any contacts profile specified for X?

I'm planning on implementing this on a 4.3 installation, if that makes any permissions difference.

Thanks in advance.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Display profile php call? Wordpress
March 04, 2013, 09:32:41 am

check:

https://github.com/civicrm/civicrm-drupal/blob/7.x-master/civicrm_user.inc

for pretty much the stuff you want to do. i.e. we retrieve the profile html in both edit and view modes for display on the drupal user reg / my account pages. Might help a lot to get a vanilla drupal install up and running wth civicrm, so u can see it in action

for the view question, in 4.3, yes, if the user has permission to view profiles. We do recommend you restrict the group that the user has permission on, else you might end up exposing a lot more data.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

dtheweather9

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 1
    • Students for the Exploration and Development of Space, USA
  • CiviCRM version: 4.4.0
  • CMS version: WordPress 3.8.1
  • MySQL version: 5.1.56
  • PHP version: 5.4.11
Re: Display profile php call? Wordpress
March 06, 2013, 02:17:41 pm
Hmm
I tried playing around with the civicrm drupal install I have, and have had problems understanding where all it comes from.  More or less from what I was looking at.  It would seem that I would need some sort of use of the information on http://civicrm.org/node/98

I tried playing around with it some, but couldn’t find too much on documentation. 

What I tried doing is currently :

<site_root>/blank/?page=CiviCRM&q=civicrm/profile/edit&gid=<Profile_id>

Will show the edit form with the fields filled in.  /blank/ is a page in wordpress setup with a custom template that only calls the page contents from the database (which is nothing in this case).   This page is pretty much what I want to display; my intial thoughts were to do file_get_contents() on the above page to try to load the page.  After a few attempts, it will nicely show the correct file contents, the form/profile, but there is no data any of the fields. 

I looked into it, and then tried curl to see if that would work better, which it was faster at least, but still gave me the same issue with displaying the form, but no data. 

Currently the below works for giving me the form, but with no data in it to be able to edit;

Code: [Select]
$url = "<site domain url>/blank/?page=CiviCRM&q=civicrm/profile/edit&gid=<Profile_id>";

session_write_close();

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);

echo $data;

I also was able to use the api to get the data for the profile and current user, but I got as far as select options before I realized I didn’t want to try to rebuild what the function buildQuickForm() &function setDefaultValues( ) already seems to do and I can't access.

Any help with getting this up and running would be appreciated, I'd guess the curl method would be easiest, but if not please let me know.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Display profile php call? Wordpress
March 06, 2013, 04:20:46 pm

You can give it a shot via curl, but u'll need to send the existing cookies etc so civi/drupal know its a logged in user

I think understanding and reusing the drupal code is probably the easiest (at least to me). we can help out on irc.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Display profile php call? Wordpress

This forum was archived on 2017-11-26.