How to access profile fields directly?

With page builder i added a new page to my site and added a PHP block to it. In this block i need to access some of the the profile fields of the currently logged in user. Is this easy to do?I tried to find some help from pedit.php but i do not get on how to access the fields because i have no general docs about the dolphin framework.

How i read and write to profile fields? If it's possible does anybody have any short example?

Many thanks in advance

Check my GeoDistance, Watermark, TorBlock and Android Push Notifications mods | http://goo.gl/H3Vp81
Quote · 9 May 2012

Reading the profile fields is easy. Dolphin has a built in function for that which just does a mysql query to read the row for that member id.

$iMemID = (int)$_COOKIE['memberID'];
$aProfileArray = getProfileInfo($iMemID);
echo $aProfileArray['NickName'] . '<br>';
echo $aProfileArray['Status'] . '<br>';

Thats an example. You can get any field in the Profile table. $aProfileArray['MyProfileField']

Now to write is a bit harder. You need to perform an mysql query.

$iMemID = (int)$_COOKIE['memberID'];
$sQuery = "UPDATE `Profiles` SET `NickName`='$newnickname' WHERE `ID`='$iMemID'";
db_res($sQuery);



See this topic for links to various docs.

http://www.boonex.com/forums/topic/Developers-Links.htm

However i learned dolphin just by studying the files in inc and the classes in inc/classes.

Those areas are pretty much where everything that powers dolphin is


https://www.deanbassett.com
Quote · 9 May 2012

Wow many thanks! I already thought i need include some classes etc. WIll play with it in your php blocks :) Thats so easy!

Check my GeoDistance, Watermark, TorBlock and Android Push Notifications mods | http://goo.gl/H3Vp81
Quote · 9 May 2012

I should mention than when you do a write to the database the cache needs to be cleared. For the profile info it's just a matter of removeing the proper user*.php file from the cache folder.

There are built in functions for the cache as well. Just do not remember them off the top of my head.



https://www.deanbassett.com
Quote · 9 May 2012

thanks i will check this out from dolphin code or the docs you gave me. btw its already working! :)

 

if i could ask you one last question about your php blocks and the dolphin framework. is there a way to create a button with php and on click it runs a function to save the changes the user made to the fields?

i think about this way....

-> php block enter -> read profile fields() -> USER changes some values in fields -> Clicks Save Button -> Write profile fields()

this server side php still makes me some headache.... maybe i need use some ajax stuff? :(

Check my GeoDistance, Watermark, TorBlock and Android Push Notifications mods | http://goo.gl/H3Vp81
Quote · 9 May 2012

They are not really my php blocks per se. PHP block ability is built into dolphin. It's just boonex never provided a way for users to create those php blocks without hacking the database manually. So i provided that way.

Anyhow, now you're getting complicated.

The key here is server-side vs client side. PHP is server-side scripting. So you cannot execute a PHP function in response to a click of a link on the client side. You can do the following.

Items to be changed can be in a form and when the button is clicked then the form is submitted. Filling out forms and submitting data is the most common way of collecting data from a user.

The other option is with JavaScript which is client side. a onclick event can be used to execute a JavaScript function that sends the values via an ajax call to another script when then records the data.

But in short, no. PHP being that it is a server-side scripting language cannot interact with the client.

So in your above example you would need to do this.

-> php block enter -> read profile fields() -> Script prepopulates a standard html form with those values. -> USER changes some values in fields -> Clicks Save Button -> Form is submitted to another script which saves the profile fields()


https://www.deanbassett.com
Quote · 9 May 2012

Thanks for your help, maybe i really was to complicated.

Even i am no web developer I know the ways of form submit hehe. I should ask different way, if i submit the result to another script etc. I loose the framework (class includes) in the destination script. So i don't know how to access it there because I don't know the class hierarchy. I could bypass the framework and write directly to the database but i am not sure if thats a good idea. Better stay in the framework.

Ok to keep it simple: What do i have to include to have access to dolphin objects, so i can write back in my own php file? Is there a template for this? Maybe i can copy from another file which has the basic includes?

Check my GeoDistance, Watermark, TorBlock and Android Push Notifications mods | http://goo.gl/H3Vp81
Quote · 10 May 2012

Another dolphin page. Or even submit the form to the same page.

Incase your not aware. You can read the passed post values in a PHP block as well.


$value_passed_from_form = $_POST['myvalue'];


https://www.deanbassett.com
Quote · 10 May 2012

You are right, i didn't know this can be done. I am not a web developer but after i read about self-submitting i was finished with the basic functionallity of my mod within 10 minutes! That was so easy and solved all my problems :)

Now i just need implement this cache cleaning you spoke about then our site can go online. I am sure i will find this info somewhere in the dolphin files.

Many many thanks Deano, you helped me alot

 

submit the form to the same page.

 

Check my GeoDistance, Watermark, TorBlock and Android Push Notifications mods | http://goo.gl/H3Vp81
Quote · 10 May 2012

Just for anybody that followed this thread.

deleteUserDataFile( $iMemID ); //Clears User Data-Cache

Check my GeoDistance, Watermark, TorBlock and Android Push Notifications mods | http://goo.gl/H3Vp81
Quote · 10 May 2012
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.