Solved

get author ID from user-avatar plugin

Posted on 2011-09-08
10
277 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to use a function in heredoc 5 23
Detect change of Select using JavaScript Only 12 46
Cannot access my wp-admin account 2 13
two layers of simple javascript validation 2 26
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now