Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author alexacrm

    (@alexacrm)

    @subash1990

    there is really not enough information to understand what the problem is.

    User registration where? WordPress? CRM? What kind of registration? Are you using form and duplicates are created? Something else?

    Can you describe the process where users are registered and where the duplicates are created?

    Thread Starter subash1990

    (@subash1990)

    I am using the Dynamic 365 plugin, recently I switch to OAuth2.0, and Now some issues occur with username and password. I have attached my old custom code, can you please help me, with how to change it as per the latest Oauth method code? This code’s purpose avoid multiple duplicate entries (Email already exists when registered)

    use AlexaCRM\CRMToolkit\Settings;
        use AlexaCRM\CRMToolkit\Client as OrganizationService;
    
    //function for processing submitted data
        add_filter('wordpresscrm_shortcodes', 'changemode', 7, 1);
    
        function changemode($shortcodes) {
    	session_start();
    	if (isset($_SESSION['contactid'])) {
    	    $contactid = $_SESSION['contactid'];
    	}
    	if (isset($_POST['entity']) && !empty($_POST['entity']['emailaddress1'])) {
    	    $options = [
    		'serverUrl' => ASDK()->settings->serverUrl,
    		'username' => ASDK()->settings->username,
    		'password' => ASDK()->settings->password,
    		'authMode' => ASDK()->settings->authMode,
    	    ];
            
    	    $serviceSettings = new Settings($options);
    	    $service = new OrganizationService($serviceSettings);
            
    
    	    $out = $service->retrieveMultiple('<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">' .
    		    '<entity name="contact">' .
    		    '<all-attributes />' .
    		    '<order attribute="fullname" descending="false" />' .
    		    '<filter type="and">' .
    		    '<condition attribute="emailaddress1" operator="eq" value="' . $_POST['entity']['emailaddress1'] . '" />' .
    		    '</filter>' .
    		    '</entity>' .
    		    '</fetch>');
    	    $count = $out->Count;
    
    	    if ($count) {
    		if (!$contactid) {
    		    if (($out->Entities[0]->propertyValues['syn_isdeleted']['Value'] == 0) && ($out->Entities[0]->propertyValues['syn_isvalidated']['Value'] == 1)) {
    			wp_redirect(getHomeUrl() . '/message');
    			exit;
    		    } else {
    			ACRM()->request->query->set('id', $out->Entities[0]->propertyValues['contactid']['Value']);
    		    }
    		}
    	    }
    	}
    	return $shortcodes;
        }
    • This reply was modified 2 years, 1 month ago by subash1990.
    Plugin Author alexacrm

    (@alexacrm)

    Why are you creating new organization service? You can simply do this

    $service = ASDK();
    $service->retrieveMultiple(...
    • This reply was modified 2 years, 1 month ago by alexacrm.
    Thread Starter subash1990

    (@subash1990)

    ok thanks, now it is working fine

    Thread Starter subash1990

    (@subash1990)

    Now is form is working, and the Form registration is successful, but I don’t want those who applied repeatedly in the same email. How to fix this, My code is mentioned below.

    use AlexaCRM\CRMToolkit\Settings;
        use AlexaCRM\CRMToolkit\Client as OrganizationService;
    
    //function for processing submitted data
        add_filter('wordpresscrm_shortcodes', 'changemode', 7, 1);
    
        function changemode($shortcodes) {
    	session_start();
        $contactid='';
    	if (isset($_SESSION['contactid'])) {
    	    $contactid = $_SESSION['contactid'];
    	}
    
    	if (isset($_POST['entity']) && !empty($_POST['entity']['emailaddress1'])) {
    	    $options = [
    		'serverUrl' => ASDK()->settings->serverUrl,
    		//'username' => ASDK()->settings->username,
    		//'password' => ASDK()->settings->password,
    		'authMode' => ASDK()->settings->authMode,
    	    ];
    	  //  $serviceSettings = new Settings($options);
    	   // $service = new OrganizationService($serviceSettings);
           $service = ASDK();
    	    $out = $service->retrieveMultiple('<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">' .
    		    '<entity name="contact">' .
    		    '<all-attributes />' .
    		    '<order attribute="fullname" descending="false" />' .
    		    '<filter type="and">' .
    		    '<condition attribute="emailaddress1" operator="eq" value="' . $_POST['entity']['emailaddress1'] . '" />' .
    		    '</filter>' .
    		    '</entity>' .
    		    '</fetch>');
    	    $count = $out->Count;
           // echo '<pre>';print_r($out);die;
    	    if ($count) {
                if (!$contactid) {
                    if (($out->Entities[0]->propertyValues['syn_isdeleted']['Value'] == 0) && ($out->Entities[0]->propertyValues['syn_isvalidated']['Value'] == 1)) {
                    wp_redirect(getHomeUrl() . '/message');
                    exit;
                    } else {
                    ACRM()->request->query->set('id', $out->Entities[0]->propertyValues['contactid']['Value']);
                    }
                }
    	    }
    	}
    	return $shortcodes;
        }
    Plugin Author alexacrm

    (@alexacrm)

    You already doing search based on the email address. The only thing that possibly wouldn’t work is the use of $out->Count – where did you get that from?

    Try $out->TotalRecordCount instead. (Note: your fetchxml must include returntotalrecordcount="true" attribute)

    Thread Starter subash1990

    (@subash1990)

    I am facing fatal error, can you help this,

    PHP Fatal error: Uncaught Error: Call to undefined function ASDK()

    How to solve this

    Plugin Author alexacrm

    (@alexacrm)

    @subash1990 do you actually have the plugin loaded? ASDK() is a global function.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Avoid multiple duplicate users’ is closed to new replies.