Utility Methods

function_exists: function_exists — Return TRUE if the given function has been defined

Syntax:

bool function_exists ( string $function_name )

Example:

<?php
if (function_exists('payroll_getcomponents')) {
    echo(
"payroll_getcomponents functions is available");
}else{
    echo(
"payroll_getcomponents functions is NOT available");
}
?>

profile2_load_by_user: Loads the profile data of a user. Takes user id as input

Syntax:

profile2_load_by_user($account, $type_name = NULL)

Example:

<?php
$userprofile
= profile2_load_by_user(3); // 3 ->uid
$leave_profile=$userprofile['leave_settings']; //Name of the Profile Type
debug($leave_profile->field_profile_field_example['und']);

$leave_profile->field_profile_field_example['und'][0]['value']='10';
$leave_profile->save(); //Saves Profile data in DB
debug($leave_profile->field_profile_field_example['und']);
?>

--
Source:
http://www.php.net/manual/en/function.function-exists.php
http://drupalcontrib.org/api/drupal/contributions!profile2!profile2.modu...

Technologies: