Functions implemented in this article:
1. Enter the forum from the original system to automatically log in and register
2. Implement pop-up boxes on this page without jumping
3.js directly initiates a registration request when the page is loaded
This function was previously handled by the
uc_user_register
function, but today it will be used when developing user space problem appear.
Project requirements
Add a forum to our original system, but user information needs to be shared.
Implementation method: Bring the user information of the original system when entering the forum, and then get the information from the forum and register directly.
Enter the forum from the original system to automatically register and log in
Prepare such a buffer page and put it in upload/template/default/touch/member/ In the page of register.htm
then we need to put the original registration code into upload/template/default /touch/member/register.htm
The reason for putting this code is thatdsicuzThere will be many parameter restrictions when submitting the form, we can just keep it as it is.
<form method="post" autocomplete="off" name="register" id="registerform" action="member.php?mod={$_G[setting][regname]}&mobile=2"> <input type="hidden" name="regsubmit" value="yes" /> <input type="hidden" id="hash" name="formhash" value="{FORMHASH}" /> <!--{eval $dreferer = str_replace('&', '&', dreferer());}--> <input type="hidden" id="referer" name="referer" value="$dreferer" /> <input type="hidden" name="activationauth" value="{if $_GET[action] == 'activation'}$activationauth{/if}" /> <input type="hidden" name="agreebbrule" value="$bbrulehash" id="agreebbrule" checked="checked" /> <!--{if $_G['setting']['sendregisterurl']}--> <input type="hidden" name="hash" value="$_GET[hash]" /> <!--{/if}--> <!--{if $secqaacheck || $seccodecheck}--> <!--{subtemplate common/seccheck}--> <!--{/if}--> </div> </form>
Then we need to directly send a request when the page is loaded, just add the following code.
Implement the pop-up box on this page, without jumping, and directly initiate a registration request when loading
The function implemented by this js code: directly initiate a registration request when the page is loaded, and then return the information , displayed directly on this page instead of jumping to another page
<script> var hash = $('#hash').val(); var referer = $('#referer').val(); $.ajax({ type:'POST', url:"member.php?mod={$_G[setting][regname]}&mobile=2" +'&inajax=1', data:{ "handlekey":"registerform", "inajax" : 1, "regsubmit" :"yes", "formhash":hash, "referer" :referer }, dataType:'xml' }) .success(function(s) { popup.open(s.lastChild.firstChild.nodeValue); evalscript(s.lastChild.firstChild.nodeValue); }) .error(function() { window.location.href = obj.attr('href'); popup.close(); }); </script>
The last step required at this time is what form to use to transmit it from the original system. This method is not provided here. I will make a simulated data.
Add your own code according to the comments in the upload/source/module/member/member_register.php method on_register
Test the effect
We register a ceshi123 account
Test post
##Why not useuc_user_register The reason for this method to register users
uc_user_register is used to register users directly, all the following information will not be obtained
The above is the detailed content of How discuz implements automatic registration and login. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

Atom editor mac version download
The most popular open source editor