Used following code to create a new user but it does not create a record.
$user = BeanFactory::newBean(‘Users’);
$user->user_name = “crmuser”;
$user->last_name = “Jhon”;
$user->status = ‘Active’;
$user->UserType = ‘RegularUser’;
$user->email1 = ‘jhon@test.com’;
$user->new_password = ‘mypass’;
$user->save();
Does user creation work via form only or can we also use Rest API to create users? Is this available via Bean too?
pgr
17 December 2019 09:51
2
I never tried this myself, but a few things that occur to me as to why it might be failing
any missing required fields?
password complexity requirements are being met?
any clues in your logs?
Okay resolved this issue by doing the following changes.
First user_hash is missing in the save list. so adding that as
$user->user_hash = md5(‘mypass’);
Secondly adding the email address via SEA method after user is saved.
$sea = new SugarEmailAddress();
$sea->addAddress($_REQUEST[‘email’], true);
$sea->save($user->id, “Users”);
I hope this helps someone. If you also want to login the NEW user as soon as the form is submitted, you can add following code to do so .
<form method="POST" action="index.php?module=Users&action=Login" id="user_login">
<input type="hidden" name="user_name" value="<?php echo $_REQUEST['email'];?>">
<input type="hidden" name="username_password" value="<?php echo $_REQUEST['username_password']; ?>">
<input type="hidden" name="module" value="Users">
<input type="hidden" name="action" value="Authenticate">
<input type="hidden" name="return_module" value="Users">
<input type="hidden" name="return_action" value="Login">
</form>
<script type="text/javascript">
document.getElementById('user_login').submit();
</script>
2 Likes
pgr
17 December 2019 10:45
4
Nice work, I am sure this will be useful for others in the future!
Wouldn’t you like to turn this into a Technical Blog post?
To add here:
https://docs.suitecrm.com/blog/
i would love to contribute this and other snippets that i have. Please send me PM on how to do that.
1 Like
pgr
21 December 2019 13:04
6
I guess it’s better if we keep talking about this publicly, that way others will be able to learn from it also
We have some Documentation about how to edit the Documentation:
https://docs.suitecrm.com/community/contributing-to-docs/
Adding a Blog post is essentially adding a new file in the blog
directory.
Do you prefer to use git
with a local copy of the site (which you can deploy locally and see the results as you progress) or do you prefer to keep it simple and just add the file into GitHub web application?
I would prefer to just have a place to post small snippets and common solutions that people face often on suitecrm.
PS: is there a way we can mark a question as Resolved?
pgr
22 December 2019 13:06
8
About the “mark as resolved” that exists as a plugin
Hi, I have noticed that when you mark posts as solved, you can only do this on the comments to an original topic post, not on the first post itself. I have seen situations where a user may posted a question, only to end up finding the answer...
Reading time: 1 mins 🕑
Likes: 9 ❤
There are many Discourse plugins, I want to test a few but for now I’m trying to be minimalistic, there is a lot to learn about Discourse itself, before we start extending it…
About the Blog, I would be quite pleased if it was updated often, and would simply be
a place to post small snippets and common solutions that people face often on suitecrm
We don’t need to blog to have only large posts, simple things will be just fine.
Have you seen my list of stuff that I would like someone to write up as blog posts?
opened 01:07PM - 05 Feb 19 UTC
Type: Questions
writing
This Issue is a big list of stuff I saw (or wrote!) on the Forums, and in other … sites, that I think could be valuable content for the Docs site.
## How to use
1. Choose one you like
1. Decide if you want to make it part of one of the Guides (admin, developer, etc) or if it's more in the nature of a Technical Blog post
1. Grab the text (if it's copyright-free) or just get the idea and write it up yourself
1. Add up-to-date screenshots for extra points
# How to use SuiteDocs
Have a look at the [How to Contribute to SuiteCRM Documentation](https://docs.suitecrm.com/community/contributing-to-docs/) guidelines which includes how to set up a local instance; tone of voice and best practises :+1:
Of course give either @pgorod, @samus-aran or other members of the @salesagility/suitecrm-core a mention if you need any help!
1 Like