Can i display on one box "Last Topics" and in another "Last Post" or "Last Comment" ?
I try w3allastopics and w3allastopicforumsids but they display the same.
Same user ID in WP
- axew3
- w3all User
- Posts: 2883
- Joined: Fri Jan 22, 2016 5:15 pm
- Location: Italy
- Contact:
Re: Same user ID in WP
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:
... 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:
-
- User w
- Posts: 16
- Joined: Thu Dec 26, 2019 5:45 am
Re: Same user ID in WP
On Last topic can display by last "topic_id" and for last post by "post_id" or i need to make sql script ...
Or something wrong ?
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>
- axew3
- w3all User
- Posts: 2883
- Joined: Fri Jan 22, 2016 5:15 pm
- Location: Italy
- Contact:
Re: Same user ID in WP
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):
do you want to move the code above into wordpress? How the shortcode or widget should be named?
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");
-
- User w
- Posts: 16
- Joined: Thu Dec 26, 2019 5:45 am
Re: Same user ID in WP
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
Like to display in web-tourist.net
Can check old site before migration but is not styled 91.196.126.30
-
- User w
- Posts: 16
- Joined: Thu Dec 26, 2019 5:45 am
Re: Same user ID in WP
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 ?
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 ?