XF 2 Tip Changing the "Joined" date of any member in Xenforo

xauUUL

I got less but I got best!
Collaborate
Registered
Joined
Jun 22, 2021
Messages
118
Points
43

Reputation:

It is enough to run the sql query I have given below from phpmyadmin.

UPDATE xf_user

SET register_date = UNIX_TIMESTAMP('yyyy-mm-dd 00:00:00')

WHERE user_id = 2

How to do it:

yyyy-mm-dd 00:00:00 enter the date you want to set,

for example 2020.01.01 ie January 1, 2020

WHERE user_id = 2 here, write the ID of the member you want to edit the date of.

Thanks :)
 

jim

Well-known member
Registered
Joined
Aug 20, 2021
Messages
112
Points
38

Reputation:

It is enough to run the sql query I have given below from phpmyadmin.



How to do it:

yyyy-mm-dd 00:00:00 enter the date you want to set,

for example 2020.01.01 ie January 1, 2020

WHERE user_id = 2 here, write the ID of the member you want to edit the date of.

Thanks :)
xauUULThanks for the share, i created a script to run this from your URL so you do not have to access PHPMyAdmin everytime

1677323056346.png


PHP:
<?php

$servername = "your_host";
$username = "db_user";
$password = "db_pass";
$dbname = "your_database";

if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['user_id'])) {
    $user_id = $_POST['user_id'];
    $timestamp = strtotime($_POST['timestamp']);

    if (!is_numeric($user_id)) {
        preg_match('\/members\/(\d+)/', $user_id, $matches);
        if (isset($matches[1])) {
            $user_id = $matches[1];
        } else {
            die("Invalid member URL");
        }
    }


    $conn = new mysqli($servername, $username, $password, $dbname);

    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }


    $sql = "UPDATE xf_user SET register_date = ? WHERE user_id = ?";

    $stmt = $conn->prepare($sql);

    $stmt->bind_param("si", $timestamp, $user_id);

    if ($stmt->execute()) {
        echo "User record updated successfully";
    } else {
        echo "Error updating user record: " . $conn->error;
    }

    $conn->close();
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Update User Registration Date</title>
</head>
<body>
    <div class="jimchangedatecontainer">
    <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST" onsubmit="return confirm('Are you sure you want to update the user registration date? This action cannot be undone.');">
        <label for="user_id"><pre id="con35">Member URL or ID:</pre></label>
        <input type="text" id="user_id" name="user_id"><br>

        <label for="timestamp"><pre id="con35">Timestamp:</pre></label>
        <input type="text" id="timestamp" name="timestamp"><br>
        <input type="button" value="Insert Current Time" onclick="insertCurrentTime()">


        <input type="submit" value="Update Registration Date">
    </form>
    </div>
</body>
<script>
function insertCurrentTime() {
    var now = new Date();
    var timestampField = document.getElementById("timestamp");
    timestampField.value = now.toISOString();
}
</script>
<style>
#con35 {
    color: grey;
}

::-webkit-scrollbar {
    width: 7px !important;
    height: 5px !important;
    background-color: #2f2d34 !important;
}

::-webkit-scrollbar-thumb {
    background-color: #893839 !important;
}

body {
    width: 7px !important;
    height: 5px !important;
    background-color: #2f2d34 !important;
}

input[type="submit"] {
    display: inline-block;
    border: 1px solid transparent;
    -webkit-transition: background-color 0.25s ease;
    transition: background-color 0.25s ease;
    font-size: 14px;
    font-weight: 700;
    border-radius: 3px;
    padding-top: 0;
    padding-right: 10px;
    padding-bottom: 0;
    padding-left: 10px;
    text-align: center;
    outline: none;
    line-height: 32px;
    height: 32px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: content-box;
    -webkit-appearance: none;
    text-transform: uppercase;
    will-change: box-shadow;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: none;
    white-space: nowrap;
    color: #ec5555;
    background: transparent;
    border-color: rgba(20, 20, 20, 0);
    font-family: 'Lato', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.4;
}
</style>
</html>
 
Top