AI Assistant
Notifications
Clear all

[Solved] How to get the ID of the WordPress user...

3 Posts
2 Users
2 Reactions
1,597 Views
Andrew Mackinnon
Posts: 12
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@hereamack)
Eminent Member
Joined: 4 years ago
[#30479]

Hi

I'm having a lot of trouble with the PHP script below that I need to run on a .php page of my WordPress website which hosts a set of wpForo forums.

I need to obtain the field wa_wpforo_profiles.userid or the field wa_users.ID relating to the user who is logged in to the WordPress website when this script runs as a .php page of my WordPress website.

I have tried using $user_id = get_current_user_id(); and it didn't work.

If there is anything that anybody can please do to help, I would really appreciate it.

I really am at a loss.  I don't know how to solve this problem at all but I have put at least four hours into it already.

Thanks a lot for any assistance you can provide.

 

Sincerely

Andrew Mackinnon

 

<?php

$servername = "redacted";
$username = "redacted";
$password = "redacted";
$dbname = "redacted";

$user_id = ???;

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

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

$sql = "UPDATE wa_wpforo_profiles SET groupid = 6, title = 'Subscriber' WHERE userid = $user_id";

$conn->query($sql);

$conn->close();

?>


2 Replies
Chris
Posts: 3610
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@chris)
Famed Member
Joined: 5 years ago

Hi @hereamack,

This is free support and we don't provide support for such custom codes.

If you need a function for your forum, you can contact Gvectors Custom Work Team for that, contact email: sales[at]gvectors.com


Andrew Mackinnon
Posts: 12
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@hereamack)
Eminent Member
Joined: 4 years ago

@Chris

Thanks a lot for letting me know.  I appreciate it!


Share: