Jackson
Jackson

Reputation: 264

How to Get POST ID from one page to another page

I have created a message system in wordpress. There s a consultation page fr each user.also a sidebar with certain menus. when the submit button is clicked the admin reviews the question and answers it. The message will be shown in the inbox sidebar menu on the same consultation page.

but whtever i tried am not getting the reply message of the corresponding user. my problem is that when i defined the link for inbox there is no id being passed.later in tht particular page whtever id s am calling its bring up the page id only and nothing else.

This is the sidebar code:

<li>
    <a href="<?php echo site_url();?>/inbox/?id=<?php echo get_current_user_id();?>"><i class="fa fa-sort-alpha-asc " aria-hidden="true"> </i> <span style="margin-left:10px;">Inbox</span>  </a>
</li>

now its bringing the id = 1. no matter which user it is.

this is the inbox code:

<?php
global $post;
$idd= $post->ID;

$title= $post->post_title;
var_dump($title);

echo "<div class= 'col-lg-4'><table style='width:500px;'><tr><td><b>Reply:</b>&nbsp;".get_post_meta( $idd, 'docreply', true)."</td></tr></div>";

echo "<div class= 'col-lg-4'><table style='width:500px;'><tr><td><b>Amount:</b>&nbsp;".get_post_meta( $idd, 'amount', true)."</td></tr></div>";

[1]: https://i.sstatic.net/9b2pL.p

Upvotes: 0

Views: 774

Answers (3)

Jackson
Jackson

Reputation: 264

Finally i have found a solution to my problem. I updated the post_meta values in to my user_meta and in the page where i need to display the data, i called the current user id and called the user_meta

Upvotes: 1

Peter Petrov
Peter Petrov

Reputation: 141

Where is the message data saved?

I see you calling the page URL with the ID of the currently logged user.

Later, you're using the ID of the page then fetching two meta values and displaying them.

If you're using post meta, use the ID of the user that is logged in and get the meta value by using get_user_meta - https://codex.wordpress.org/Function_Reference/get_user_meta

More code would help solve this easier :)

Upvotes: 1

Shital Marakana
Shital Marakana

Reputation: 2887

you can get the post id by using get_the_ID() function.

<?php
echo get_the_ID();
?>

Upvotes: 1

Related Questions