(added in v3.2.10)

The user API contains all API calls for creating and retrieving media (files/photos/vtours) info.


Methods: user__    


create($data) - Used to create a new user:

create(array $data) : array


Returns: (array)

['error'] - TRUE/FALSE - Error status of the create request

['error_msg'] - TEXT - Error message returned (if ['error'] = TRUE).

['user_id'] - INT - Numeric listing ID# of the newly created listing


Parameters:

$data (array)

Expects an array containing the following array keys:


$data['user_details'] - ARRAY/TEXT - This should be an array containing the following.

$data['user_details']['user_name'] - TEXT- REQUIRED. This is the user's account user name.

$data['user_details']['user_first_name'] - TEXT - REQUIRED. This is the user's First Name

$data['user_details']['user_last_name'] -TEXT - REQUIRED. This is the user's Last name.

$data['user_details']['emailaddress'] - TEXT - REQUIRED. This is the user's email address.

$data['user_details']['user_password'] - TEXT - REQUIRED. This is the user's password.

$data['user_details']['active'] - TEXT - OPTIONAL - yes/no Make the user active. Defaults to no

$data['user_details']['is_admin'] - TEXT - OPTIONAL - yes/no Grant this Admin privileges. Defaults to 'no'

$data['user_details']['is_agent'] - TEXT - OPTIONAL - yes/no create this user as an Agent. Defaults to 'no'

$data['user_fields'] - ARRAY/MIXED - OPTIONAL The data you wish to insert for this user for any custom user fields. Fields like 'phone' or 'mobile'. The array keys should reference the Field Names and the array values should be the Field Values. Only valid fields will be used, other key/data pairs will be dropped.


create a new Agent who is active. Insert data for a couple of existing user defined fields.

<?php

       //creates a new active Agent user 

       $result = $api->load_local_api('user__create',array(

               'user_details'=>array(

                       'user_name' => 'timuser',

                       'user_first_name' =>'Tim',

                       'user_last_name' =>'Userby',

                       'emailaddress' =>'timmeh@somedomain.com',

                       'user_password' =>'password',

                       'active' =>'yes',

                       'is_admin' =>'no',

                       'is_agent' =>'yes'

               ),

               'user_fields' => array(

                       'phone' => '555-987-6543',

                       'mobile' => '555-123-4567'

               )

               

       ));

       // format and output the contents of the $result array so the keys

       // and values can be seen.

       echo '<pre>';

       print_r($result);

       echo '</pre>';

?>




delete($data) - Used to delete a user completely. Any listings or media belonging to them is also removed.

delete(array $data) : array


Returns: (array)

['error'] - TRUE/FALSE - Error status of the delete request

['error_msg'] - TEXT - Error message returned (if ['error'] = TRUE).

['user_id'] - INT - Numeric userdb_id of the user deleted.


Parameters:

$data (array)

Expects an array containing the following array keys:

$data['user_id'] - INT - Numeric userdb_id of the user to delete.


example:

<?php

       //deletes userdb_id #4 and any associated listings and media

       $result = $api->load_local_api('user__delete',array(

                               'user_id'=>4

       ));

       // format and output the contents of the $result array so the keys

       // and values can be seen.

       echo '<pre>';

       print_r($result);

       echo '</pre>';

?>




read($data) - Used to read/retrieve user data for a specific user.

read(array $data) : array


Returns: (array)

['error'] - TRUE/FALSE - Error status of the read request

['error_msg'] - TEXT - Error message returned (if ['error'] = TRUE).

['user'] - ARRAY - Array containing information and settings relevant to the user requested. Array keys within ['user] correspond to their OR user_db table column names (system fields) or any custom field names. The following keys refer to OR's system fields which are always available, any custom (user definable) fields such as "phone " or "Fax" will be unique to each OR install.

['user']['userdb_id'] - INT -  

['user']['userdb_user_name'] - TEXT - The user's account's user name.

['user']['userdb_emailaddress'] - TEXT - The user's First Name

['user']['userdb_user_first_name'] - TEXT -

['user']['userdb_user_last_name'] - TEXT -

['user']['userdb_comments'] - TEXT -

['user']['userdb_user_password'] - TEXT -

['user']['userdb_is_admin'] - TEXT -

['user']['userdb_can_edit_site_config'] - TEXT -

['user']['userdb_can_edit_member_template'] - TEXT -

['user']['userdb_can_edit_agent_template'] - TEXT -

['user']['userdb_can_edit_listing_template'] - TEXT -

['user']['userdb_creation_date'] - DATE -

['user']['userdb_can_feature_listings'] - TEXT -

['user']['userdb_can_view_logs'] - TEXT -

['user']['userdb_last_modified'] - TIMESTAMP -

['user']['userdb_hit_count'] - INT -

['user']['userdb_can_moderate'] - TEXT -

['user']['userdb_can_edit_pages'] - TEXT -

['user']['userdb_can_have_vtours'] - TEXT -

['user']['userdb_is_agent'] - TEXT -

['user']['userdb_active'] - TEXT -

['user']['userdb_limit_listings'] - INT -

['user']['userdb_can_edit_expiration'] - TEXT -

['user']['userdb_can_export_listings'] - TEXT -

['user']['userdb_can_edit_all_users'] - TEXT -

['user']['userdb_can_edit_all_listings'] - TEXT -

['user']['userdb_can_edit_property_classes'] - TEXT -

['user']['userdb_can_have_files'] - TEXT -

['user']['userdb_can_have_user_files'] - TEXT -

['user']['userdb_blog_user_type'] - INT -

['user']['userdb_rank'] - INT -

['user']['userdb_featuredlistinglimit'] - INT -

['user']['userdb_email_verified'] - TEXT -

['user']['userdb_can_manage_addons'] - TEXT -

['user']['userdb_can_edit_all_leads'] - TEXT -

['user']['userdb_can_edit_lead_template'] - TEXT -

['user']['userdb_send_notifications_to_floor'] - BOOL - 1 = yes


Parameters:

$data (array)

Expects an array containing the following array keys:

$data['user_id'] - INT - This is the numeric OR userdb_id of the user you wish to access.

$data['resource'] - TEXT - Type of user to read: 'agent' or 'member'

$data['fields'] - ARRAY/TEXT - This is an optional array of fields to retrieve, if left empty or not passed all fields and info will be retrieved.


Example: retrieve all info for all fields for Agent, user_id #4

<?php

       //retrieve all info for Agent, user_id #4

       $result = $api->load_local_api('user__read',array(

               'user_id'=>4,

               'resource' => 'agent'

       ));

       // format and output the contents of the $result array so the keys

       // and values can be seen.

       echo '<pre>';

    print_r($result);

echo '</pre>';

?>


Example: retrieve specific field info info for a Member, userdb_id #30

<?php

       //gets specific info for Member, userdb_id #30

       $result = $api->load_local_api('user__read',array(

               'user_id' => 30,

               'resource' => 'member',

               'fields' => array(

                       'userdb_emailaddress',

                       'userdb_creation_date',

                       'userdb_last_modified',

                       'userdb_hit_count'

               )

       ));

       // format and output the contents of the $result array so the keys

       // and values can be seen.

       echo '<pre>';

    print_r($result);

echo '</pre>';

?>




search($data) - Used to search user data:

search(array $data) : array


Returns: (array)

The array returned will contain the following:

['error'] - TRUE/FALSE - Error status of the search request

['error_msg'] - TEXT - Error message returned (if ['error'] = TRUE).

['user_count'] = Number of records/users found that match the search, if using a limit this is only up to the number of records that match your current limit/offset results.

['users'] = Array of user ID#s that match the search.

['info'] = The info array contains benchmark information on the search, includes: process_time, query_time, and total_time

['sortby'] = Contains an array of fields that were used to sort the search results. Note if you are doing a count only search the sort is not actually used as this would just slow down the query.

['sorttype'] = Contains an array of the sorttype (ASC/DESC) used on the sortby fields.

['limit'] - INT - The numeric limit being imposed on the results.

['resource'] - TEXT - The resource the search was made against, 'agent' or 'member'


Parameters:

$data (array)

Expects an array containing the following array keys:

$data['resource'] - TEXT - REQUIRED - Type of user to search: 'agent' or 'member'. Used for min/max, number or price searches only.

$data['parameters'] - This is a REQUIRED array of the fields and the values we are searching for.

$data['sortby'] - This is an optional array of fields to sort by.

$data['sorttype'] - This is an optional array of sort types (ASC/DESC) to sort the sortby fields by.

$data['offset'] - This is an optional integer of the number of users to offset the search by. To use offset you must set a limit.

$data['limit'] - This is an optional integer of the number of listings to limit the search by. 0 or unset will return all listings.

$data['count_only'] - This is an optional integer flag 1/0, where 1 returns a record count only, defaults to 0 if not set. Useful if doing limit/offset search for pagination to get the initial full record count..


example:

<?php

       //get the userdb_id for all Members active or not, sort results by userdb_id in ASC order

       $result = $api->load_local_api('user__search',array(

               'parameters'=>array(

                       'userdb_is_agent' =>'no',

                       'userdb_active' =>'any'

               ),

               'sortby'=>array('userdb_id'),

               'sorttype'=>array('ASC'),

               'resource' =>'member',

               'limit'=>0,

               'offset'=>0,

               'count_only'=>0

       ));

       // format and output the contents of the $result array so the keys

       // and values can be seen.

       echo '<pre>';

       print_r($result);

       echo '</pre>';

?>


update($data) - Used to update a specific user.

update(array $data) : array


Returns: (array)

['error'] - TRUE/FALSE - Error status of the delete request

['error_msg'] - TEXT - Error message returned (if ['error'] = TRUE).

['user_id'] - INT - Numeric userdb_id  ID# of the updated user


Parameters:

$data (array)

Expects an array containing the following array keys:

$data['user_id'] - INT - REQUIRED - This is the userdb_id ID of the user you are updating.

$data['user_details'] - ARRAY - An array containing one or more of the following OPTIONAL keys.

$data['user_details']['active'] - BOOL - OPTIONAL - Set true to make this listing Active. Only set if you need to change.

$data['user_details']['blog_user_type'] - INT - OPTIONAL - The Agent's blogging privilege level:

1 = Subscriber

2 = Contributor

3 = Author

4 = Editor

$data['user_details']['can_edit_agent_template'] - BOOL - OPTIONAL - Agent can create and edit Agent fields

$data['user_details']['can_edit_all_leads'] - BOOL - OPTIONAL - Agent can create and edit any leads in the Lead Manager

$data['user_details']['can_edit_all_listings'] - BOOL - OPTIONAL - Agent can create and edit other Agent's Listings

$data['user_details']['can_edit_all_users'] - BOOL - OPTIONAL - Agent can edit other users via User Manager

$data['user_details']['can_edit_expiration'] - BOOL - OPTIONAL - Agent can set listing expiration dates.

$data['user_details']['can_edit_lead_template'] - BOOL - OPTIONAL - Agent can create and edit Lead Manager fields

$data['user_details']['can_edit_listing_template'] - BOOL - OPTIONAL - Agent can create and edit Listing  fields

$data['user_details']['can_edit_member_template'] - BOOL - OPTIONAL - Agent can create and edit Member fields

$data['user_details']['can_edit_pages'] - BOOL - OPTIONAL - Agent can create and edit Page Editor Pages

$data['user_details']['can_edit_property_classes'] - BOOL - OPTIONAL - Agent can create and edit Property Classes

$data['user_details']['can_edit_site_config'] - BOOL - OPTIONAL - Agent can access and set Site Config options.

$data['user_details']['can_export_listings'] - BOOL - OPTIONAL - Agent can set listings to be featured.

$data['user_details']['can_feature_listings'] - BOOL - OPTIONAL - Agent can set listings to be featured.

$data['user_details']['can_have_files'] - BOOL - OPTIONAL - Agent can upload listing files such as PDF.

$data['user_details']['can_have_user_files'] - BOOL - OPTIONAL - Agent can upload files associated with their profile

$data['user_details']['can_have_vtours'] - BOOL - OPTIONAL - Agent can upload listing vtours.

$data['user_details']['can_manage_addons'] - BOOL - OPTIONAL - Agent can operate add-on Manager

$data['user_details']['can_moderate'] - BOOL - OPTIONAL - Agent can moderate other users

$data['user_details']['can_view_logs'] - BOOL - OPTIONAL - Agent can view the Activity Log

$data['user_details']['comments'] - TEXT - OPTIONAL - Comment. Not visible to regular users

$data['user_details']['email_verified'] - BOOL - OPTIONAL - This user was email verified when the account was created.

$data['user_details']['emailaddress'] - TEXT - The user's email address

$data['user_details']['featuredlistinglimit'] - INT - OPTIONAL - The maximum number of listings an Agent can set to be featured.

$data['user_details']['hit_count'] - INT - OPTIONAL - THe number of hits (views) the Agent has received.

$data['user_details']['limit_listings'] - INT - OPTIONAL - The maximum number of listings an Agent can create. -1 = unlimited.

$data['user_details']['rank'] - INT - OPTIONAL - The user's order or rank. 0 = hidden.

$data['user_details']['send_notifications_to_floor'] - BOOL - OPTIONAL - Automatically forward this Agent's leads to the floor Agent.

$data['user_details']['user_first_name'] - TEXT - OPTIONAL - The user's first name

$data['user_details']['user_last_name'] - TEXT - OPTIONAL - The user's last name

$data['user_details']['user_password'] - - TEXT - OPTIONAL - The user's password..


example:

<?php

//updates an existing user, setting it to inactive

//and changing its password, and phone number custom user field at the same time

$result = $api->load_local_api('user__update',array(

  'user_id' => 30,

  'user_details'=>array(

    'active' => false,

    'user_password' =>'password',

  ),

  'user_fields' => array(

    'phone' => '555-555-1212',

  )

));

// format and output the contents of the $result array so the keys

// and values can be seen.

echo '&lt;pre>';

print_r($result);

echo '&lt;/pre>';

</code></pre>

?>