Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

get author ID from user-avatar plugin

Posted on 2011-09-08
10
Medium Priority
?
288 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

916 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