Solved

get author ID from user-avatar plugin

Posted on 2011-09-08
10
283 Views
Last Modified: 2012-08-14
when a member is logged into my membership site, and posts a comment on my blog, their photo gets displayed. I'd like to be able to return the id of the author logged in so I can display their photo on a page.  When I view the source code, the path is:

http://www.domain.com/wp-content/plugins/user-avatar/user-avatar-pic.php?id=21

As you can see I'm using the user-avatar plugin.  How can I dynamically pull the id and place that author id in the url above?  I do have a plugin called exec-php so I can embed php into the page.

Any ideas?

0
Comment
Question by:COwebmaster
  • 5
  • 4
10 Comments
 
LVL 8

Expert Comment

by:PranjalShah
ID: 36507078
I am not familiar with the user-avatar plugin. But if you have a table with the user photos then there should be relationship between the member and its photo. You can put the member id from the table in the URL. Say for the above URL the photo belongs to some member id 3 then you can have

http://www.domain.com/wp-content/plugins/user-avatar/user-avatar-pic.php?id=21&mid=3

Now you can fetch the member info from the member table with the corresponding mid
0
 

Author Comment

by:COwebmaster
ID: 36507674
Yes, I understand that but just need the php code to pull back dynamically the author id.  Any ideas on that?
0
 
LVL 8

Expert Comment

by:PranjalShah
ID: 36508146
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:COwebmaster
ID: 36513357
Okay, so this is what that thread has.

However, I need to display the author image.  How can I obtain that?
<a href="details.php?id={$row['id']}">read more...</a>

then on detail.php all you need is:
<?php

if( isset($_GET['id']) && !empty($_GET['id']) )
{
  mysql_connect('localhost','username','password') or die( mysql_error() );
  mysql_select_db('databaseName') or die( mysql_error() );
  $sql='SELECT * FROM TableName WHERE id='.mysql_real_escape_string($_GET['id']);
  $result=mysql_query($sql) or die('Unable to execute <br />'. htmlentities($sql,ENT_QUOTES). '<br />'. mysql_error() );

  while($row=mysql_fetch_assoc($result) ){
    //assuming you have a description field
    echo $row['description'];
  }
}
exit;
?>

Open in new window

0
 
LVL 8

Accepted Solution

by:
PranjalShah earned 500 total points
ID: 36513412
The $_GET variable in this example is id and in the example i showed for URL your GET variable will be mid. So get the info from the member table where memberid=$_GET['mid'] and change the query accordingly
0
 

Author Comment

by:COwebmaster
ID: 36531065
I've requested that this question be closed as follows:

Accepted answer: 0 points for COwebmaster's comment http:/Q_27298834.html#36513357

for the following reason:

thanks PranjalShah
0
 

Author Comment

by:COwebmaster
ID: 36529870
I clicked on the wrong answer.  Please remove this selection.
0
 
LVL 8

Expert Comment

by:PranjalShah
ID: 36531066
You can not accept your own comment as a solution. That comment also comes from the link I posted
0
 

Author Closing Comment

by:COwebmaster
ID: 36532835
Thanks!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question