Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to add custom code to user registration?


  • volcore
    Participant

    @volcore

    While I’ve added custom fields to a user’s registration on a site of mine, I want to use some custom code to login to a SQL database and check the given ID with the IDs in the database. I’ve already got code to do so,

    
    <?php
    include_once('dbconnect.php');
    //if(isset($_POST['search'])){
    	$q = $_POST['q'];
    	$q = $_GET['query']; 
    	session_start();
    		session_start();	
    		session_start();
    
    	$query = mysqli_query($conn,"SELECT * FROM <code>Persons</code> WHERE <code>id</code> LIKE '%$q%'"); 
    //Replace table_name with your table name and <code>thing_to_search</code> with the column you want to search
    	$count = mysqli_num_rows($query);
    	if($count != "1"){
    		$output = '<h2>No result found!</h2>';
    	}else{
    		while($row = mysqli_fetch_array($query)){
    		$s = $row['name']; // Replace column_to_display with the column you want the results from
    				$output .= '<h2> Found: '.$s.'</h2><br>';
    			}
    		}
    		$_SESSION['name'] = $s;
    		$_SESSION['id'] = $q;
    		$_SESSION['fromMain'] = "true";
    		echo $_SESSION['fromMain'];
    	//}
    ?>
    

    How exactly would I connect the above PHP code to the registration of a potential user? Additionally, would there need to be any changes to the code to make it work?

    WP: 5.1.1
    BP: 4.2.0
    Site: http://worldcubers.com/

Viewing 3 replies - 1 through 3 (of 3 total)

  • Venutius
    Moderator

    @venutius

    You could probably hook this up to the action bp_core_signup_user however your code looks like it’s trying to work with the search page, not the registration page.


    volcore
    Participant

    @volcore

    The code was just copied from an earlier version of the site before I found out about multisites and BuddyPress. Where exactly do I put the code, and what would I modify about it to make it work?


    volcore
    Participant

    @volcore

    Anything?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar