Solved

get author ID from user-avatar plugin

Posted on 2011-09-08
10
275 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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:COwebmaster
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Accepted Solution

by:
PranjalShah earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
I clicked on the wrong answer.  Please remove this selection.
0
 
LVL 8

Expert Comment

by:PranjalShah
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This video teaches users how to migrate an existing Wordpress website to a new domain.
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…

744 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

15 Experts available now in Live!

Get 1:1 Help Now