Allow users to register

Is there a way to allow users to register - potentially through Wordpress, giving them a user account in SuiteCRM?

Thanks in advance!

Not out-of-the-box, no.

Are you sure you want them as “Users” in SuiteCRM? Wouldn’t “Portal Users” be more adequate? Anyway I don’t think registration could be totally automatic without some code customizations.

Here is some background reading on portal users: https://pgorod.github.io/Concepts-Users-Employees/

1 Like

You can get a registration form for SuiteCRM in an upgrade safe manner by using the Rest API.
You need to write a custom PHP script within your website. You can try the following code:


// Open a curl session for making the call 
$curl = curl_init(); 
$url = $site . '/suite/service/v4_1/rest.php'; 
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);

$postArgs = 'method=login&input_type=JSON&response_type=JSON&rest_data={"user_auth":{"user_name":"your_dedicated_admin_user","password":"hashed_PW"},"application_name":"Some_name"}'; 

curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs); 
$response = curl_exec($curl); 
$result_login = json_decode($response); 

//Check if User is logged in
if(!isset($result_login->{'id'})){
	$error = true;
	$error_message = '<li>REST Login error!</li>';
	curl_close($curl);  
	break;
}

// Make sure you PROTECT YOUR INPUTS properly!

//Check if Username exists already
$parameters = array(
	'session' => $result_login->{'id'}, 
	'module_name' => 'Users',
	'query' => "(users.user_name LIKE '".$field_username."')",
	'order_by' => '',
	'offset' => '0',
	'select_fields' => array(
		'id',
		'user_name',
		'date_entered'
	),
	'link_name_to_fields_array' => array(
	),
	'max_results' => '1',
	'deleted' => '0'
);    
$json = json_encode($parameters);    
$postArgs = 'method=get_entry_list&input_type=JSON&response_type=JSON&rest_data=' . $json; 
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs); 
$response = curl_exec($curl); 
$result = json_decode($response); 

if($result->result_count > 0){
	$error = true;
	$error_message = '<li>user_name already exists</li>';
	curl_close($curl);  
	break;
}		

//Check if email exists already
$parameters = array(
	'session' => $result_login->{'id'}, 
	'module_name' => 'Users',
	'query' => "users.id in (
SELECT eabr.bean_id
FROM email_addr_bean_rel eabr JOIN email_addresses ea
ON (ea.id = eabr.email_address_id)
WHERE eabr.bean_module = 'Users' AND eabr.deleted=0 AND eabr.primary_address=1 AND ea.email_address = '" . $field_email . "')",
	'order_by' => '',
	'offset' => '0',
	'select_fields' => array(
		'id',
		'user_name',
		'date_entered'
	),
	'link_name_to_fields_array' => array(
	),
	'max_results' => '1',
	'deleted' => '0'
);    
$json = json_encode($parameters);    
$postArgs = 'method=get_entry_list&input_type=JSON&response_type=JSON&rest_data=' . $json; 
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs); 
$response = curl_exec($curl); 
$result = json_decode($response,true); 

if($result->result_count > 0){
	$error = true;
	$error_message = '<li>Email already registered</li>';
	curl_close($curl);  
	break;
}

//Create user
$parameters = array( 
	'session' => $result_login->{'id'}, 
	'module' => 'Users', 
	'name_value_list' => array( 
		array('name' => 'user_name', 		'value' => $field_username), 
		array('name' => 'first_name', 		'value' => $field_firstname), 
		array('name' => 'last_name', 		'value' => $field_lastname), 
		array('name' => 'email1', 			'value' => $field_email), 
		array('name' => 'description',	 	'value' => $field_description), 
		array('name' => 'is_admin', 		'value' => '0'), 
		array('name' => 'status', 			'value' => 'Inactive'), 
	), 
); 
$json = json_encode($parameters); 
$postArgs = 'method=set_entry&input_type=JSON&response_type=JSON&rest_data=' . $json; 
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs); 
$response = curl_exec($curl); 
$result_user = json_decode($response); 

if(!isset($result_user->{'id'})){
	$error = true;
	$error_message .= '<li>REST User creation failed!</li>';
	curl_close($curl);  
	break;
}

Hope, that this helps!
Best regards

2 Likes

Thankyou you two, you’ve been a great help :slight_smile:

I’m having another problem now. I get an HTTP error 500. Now this is also an error I get when viewing/downloading documents I have uploaded.

Anyway the link is:http://kevin.executivestrategy.co.uk/portal/portal-login.php

BTW, I changed $site to /portal/service/v4_1/rest.php so that it points to the right directory