Solved

get author ID from user-avatar plugin

Posted on 2011-09-08
10
282 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

810 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