{"id":4360,"date":"2022-07-07T10:43:02","date_gmt":"2022-07-07T09:43:02","guid":{"rendered":"https:\/\/ibex.tech\/wordpress-sites\/?p=4360"},"modified":"2022-07-13T12:28:13","modified_gmt":"2022-07-13T11:28:13","slug":"add-new-user","status":"publish","type":"post","link":"https:\/\/ibex.tech\/wordpress-sites\/plugins\/buddypress\/members\/add-new-user","title":{"rendered":"Add new user"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Adding a new user to BuddyPress in code<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/**********************************\n\/\/**********************************\n\/\/********** ADD NEW USER **********\n\/\/**********************************\n\/\/**********************************\nfunction add_a_new_user ($added_by_user_id, $user_name, $user_password, $user_email)\n{\n  \n  \/\/Use the BuddyPress new user creation process\n  $user_id = bp_core_signup_user($user_name, $user_password, $user_email, array());\n  if (is_wp_error($user_id))\n  {\n    \/\/USER COULD NOT BE CREATED \n    return(False);\n  }\n\n  \n  \/\/----- USER WAS CREATED -----\n  \n  \/\/SET MEMBER TYPE (optional)\n  bp_set_member_type($user_id, 'my_custom_member_type');\n\n  \/\/SET NEW USER TO BE A FRIEND OF THIS USER (optional)\n  friends_add_friend($added_by_user_id, $user_id, true);    \/\/$force_accept = true\n  \n  return($user_id);\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Adding a new user to BuddyPress in code<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[361],"tags":[],"class_list":["post-4360","post","type-post","status-publish","format-standard","hentry","category-members"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/comments?post=4360"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4360\/revisions"}],"predecessor-version":[{"id":4408,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4360\/revisions\/4408"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/media?parent=4360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/categories?post=4360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/tags?post=4360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}