How can I create a new user—with Profile 2 fields—programmatically?
I load the profile object:

$profile = profile2_by_uid_load($user-&gt;uid, '&lt;role type here&gt;');


Then I edit the $profile object.

I have a Rules component that saves the profile object. I forget why I have the rule but I remember that it requires quite a bit of code and database queries to get it right.

I set the Rules component to take the $profile object as an argument / parameter and invoke it like this.

    rules_invoke_component('rules_machine_name_this_is_the_component_url_too', $profile);