Same user ID in WP

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

If you wish to attach one or more files enter the details below.

Maximum filesize per attachment: 1 MiB.

Expand view Topic review: Same user ID in WP

Re: Same user ID in WP

by axew3 » Fri Jan 24, 2020 11:27 am

So, the scenario is, you let register users in phpBB, then an user register into phpBB, and is added in WordPress, as subscriber, while you would like him added into wp Contributor group instead?
... looking ...
ah nice one!
Well, the actual code unchanged from long time, just do this, you're right:
admin in phpBB -> admin in wp
moderator in phpBB -> editor in wp
all others, as subscribers.

On the wild, you could change code with easy to accomplish with this.
And i assume will work.

Into file:
class.wp.w3all-phpbb.php
search for this line, (two times into file, same instruction, change both):

Code: Select all

 }  else { $role = 'subscriber'; }  // for all others phpBB Groups default to WP subscriber
change into:

Code: Select all

 }  else { $role = 'contributor'; }  // for all others phpBB Groups default to WP subscriber
then open wp_w3all.php and do the same into a single line, like the above.

We can provide option for this, so do this until 2.1.2, which will provide an option to add new coming phpBB users, into a specified WP group.
This option will be available since 2.1.2 next coming.

Re: Same user ID in WP

by muti » Fri Jan 24, 2020 10:50 am

Hi,
in WP on Settings > General New User Role is set to Contributor. But linked users have Subscriber role. How to change to set automatic role Contributor ?

Re: Same user ID in WP

by muti » Tue Jan 14, 2020 6:29 pm

Like to display last topics in static WP page.
Like to display in web-tourist.net
Can check old site before migration but is not styled 91.196.126.30

Re: Same user ID in WP

by axew3 » Mon Jan 13, 2020 8:46 pm

Well, may you're over complicating things.
Beside the fact i should run the query that we assume is correct, where you want to display the result?
In WordPress? Because the code you present is may suitable to run into phpBB side, not wordpress.

The query use variables and the way/style phpBB do things, not the wordpress way that basically is based into ezSQL library style.

a query into wp_w3all plugin, that since i use ezSQL even before WP, i use with old wild style, and not this
https://developer.wordpress.org/referen ... b/prepare/
that over complicate things for me, i know that not secure values needs to be passed on queries wrapped like this:
$w3db_conn->get_results(" SELECT * FROM topics where aVal = ' ".$var." ' ");
substantially wrapping/casting $vars like this ' " . $var . " ' (i give a white space to make it more clear the way it need to be)
and not this way:
$w3db_conn->get_results("SELECT * FROM topics where aVal = $var");
and not like this:
$w3db_conn->get_results("SELECT * FROM topics where aVal = ".$var.");
if you're not secure of what data are coming in. And i normally by the way like to know (sanitize) everything is coming in.

So a query in wp is more easy then in phpBB, like this (look that $w3all_config["table_prefix"] can be a more easy named var or even not a var so all result even much more readable):

Code: Select all

   $topics = $w3db_conn->get_results("SELECT T.*, P.*, U.* 
    FROM ".$w3all_config["table_prefix"]."topics AS T
    JOIN ".$w3all_config["table_prefix"]."posts AS P on (T.topic_last_post_id = P.post_id and T.forum_id = P.forum_id)
    JOIN ".$w3all_config["table_prefix"]."users AS U on U.user_id = T.topic_last_poster_id
    WHERE T.topic_visibility = 1
    AND T.forum_id IN(".$gf.")
    AND P.post_visibility = 1
    ORDER BY T.topic_last_post_time DESC
    LIMIT 0,$ntopics");
do you want to move the code above into wordpress? How the shortcode or widget should be named?

Re: Same user ID in WP

by muti » Mon Jan 13, 2020 4:55 pm

On Last topic can display by last "topic_id" and for last post by "post_id" or i need to make sql script ...


Code: Select all

<body bgcolor="black" link="blue" alink="blue" vlink="blue"><font size="1" color="blue"><center>Last 10 topics</center>
<?

function mysqlerror($err) {
global $mysql;

if ($mysql == "off") return;
echo $err . "<br><b>" . mysql_error() . "</b>";
exit;
}

function mysqlconnect() {
global $mysqlid, $mysqlhost, $mysqllogin, $mysqlpass, $mysqldb;
if ($mysqlid) return;
$mysqlid = mysql_connect($mysqlhost, $mysqllogin, $mysqlpass) or mysqlerror("Can not connect to $mysqlhost");
mysql_select_db($mysqldb, $mysqlid) or mysqlerror("Missing DB $mysqldb");
}

function mysqlclose() {
global $mysqlid;
if ($mysqlid) @mysql_close($mysqlid);
}

function mysqlquery($sql) {
global $mysqlid;
if (!$mysqlid) mysqlconnect();
$res = mysql_query($sql, $mysqlid) or mysqlerror($sql);
return $res;
}

register_shutdown_function("mysqlclose");

// MySQL loading ----------------------------------------------
$mysqlid = 0;
$mysqlhost = 'Host';
$mysqldb = 'DB';
$mysqllogin = 'User';
$mysqlpass = 'Pass';
mysqlconnect();
// END MySQL loading ----------------------------------------------

$table_prefix = "Tabble prefix phpbb_";
$forum_url = "http://Forum URL";
$news_forum_id = 2;
$number_of_news = 10;
$date_format = "d.m.Y, G:i:s";

$query = "SELECT
t.`topic_id`,
t.`topic_title`,
p.`post_time`,
p.`post_username`,
p.`poster_id`,
u.`username`

FROM
`" . $table_prefix . "topics` as t,
`" . $table_prefix . "posts` as p,
`" . $table_prefix . "posts_text` as pt,
`" . $table_prefix . "users` as u
WHERE
t.`topic_first_post_id` = p.`post_id` AND
t.`topic_first_post_id` = pt.`post_id` AND
p.`poster_id` = u.`user_id` AND
t.`forum_id` = '" . $news_forum_id . "'
ORDER BY p.`post_time` DESC
LIMIT $number_of_news";
$result = mysqlquery($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<br>
<a href="<?= $forum_url ?>viewtopic.php?t=<?= $row['topic_id'] ?>">
<?= $row['topic_title'] ?>
<?= nl2br($row['post_text']) ?>

<? } ?>
</font></body>
Or something wrong ? :)

Re: Same user ID in WP

by axew3 » Mon Jan 13, 2020 2:33 pm

Last Post concept (ehy! what happened to the uploaded img?) i will try to test an attach here to see what happen, if images show fine ...
... Last post concept is this:

display Last Updated or inserted New Topic


That contain at same time, so:
OR
last new topics inserted on forums
AND/OR
last topics updated containing new replies

No you can't retrieve only post's replies as code is, results will contain also new topics.

w3allastopics and w3allastopicforumsids aren't the same and the result is different, depend on how you use as parameters, but are different things that leads to different results.

Only last post, mean that any new topic contain a new post, so the logic is correct. Except if you like to display only posts that aren't the first, but to achieve what? May i've not well understand this.
When you say last comment what it mean?

sorry, i test an img attach here:
fox.jpg
fox.jpg (80.83 KiB) Viewed 4954 times

Top