Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Sidebars & Widgets (http://forum.bytesforall.com/forumdisplay.php?f=14)
-   -   New Widget Area named after logged user ID (http://forum.bytesforall.com/showthread.php?t=9587)

thanos Sep 12, 2010 06:29 AM

New Widget Area named after logged user ID
 
Hi,
I've been using Atahualpa for a long time but never had to post something in the forum as I always find what I'm looking for here..

What I want to do in my new web site is to automatically create a new widget area for every user that subscribes to it and name it after his/her id and last name (example: 2 Smith).

I can get the user info with this piece of code:

php global $current_user;
get_currentuserinfo();

echo 'Username: ' . $current_user->user_login . "\n";
echo 'User email: ' . $current_user->user_email . "\n";
echo 'User level: ' . $current_user->user_level . "\n";
echo 'User first name: ' . $current_user->user_firstname . "\n";
echo 'User last name: ' . $current_user->user_lastname . "\n";
echo 'User display name: ' . $current_user->display_name . "\n";
echo 'User ID: ' . $current_user->ID . "\n";

What I'm looking for is the way to place the data from $current_user->ID and $current_user->user_lastname inside the command (bfa_widget_area('name=My new widget area') for creating the new widget areas.

I'm using Wordpress 3.0.1 and Atahualpa 3.5.3
My php skills are very very limited...

Thanks

lmilesw Sep 13, 2010 05:37 AM

I would advise against this even if you found a way to do it. Let's assume you found a way to create the widget area. Then you could potentially have many widget areas showing up in Appearance>Widgets which would eventually get hard to navigate and you would have to populate those widget areas with widgets which would eventually add a lot of overhead on your server causing performance issues.

With that said what is your purpose for creating the new widget areas for each subscriber? Maybe there is a better solution for what you want to accomplish.

thanos Sep 13, 2010 06:51 AM

Hi Larry and thanks for your reply.

The purpose is to give each subscriber a different update only for him.. A text widget will do just fine..
There will not be many subscribers so I don't worry about server load or having too many widgets.

I couldn't think of a better way to do this. I'm open to any ideas or suggestions you may have.

Thanks

juggledad Sep 13, 2010 07:13 AM

I'm not sure what you want to put in the update, but why not put some code in a text widget and tie off the user that is logged in - you will need the exec-php widget or another widget like that but you could use something like this
HTML Code:

<?php global $current_user;
get_currentuserinfo();
$who_is_user = $current_user->
user_login;
if (!$who_is_user) {
  echo "Hey, if you login, we can offer more info!";}
else {
  echo 'Welcome back, ' . $who_is_user . "\n";}
?>


thanos Sep 13, 2010 07:38 AM

Hi juggledad. Thanks for taking the time to reply.

Here's an example of what i want to do:

Let's say that you and Larry are my subscribers.
When you log in you can both see the posts in my blog but i also have a picture that is only for you to see and another picture that is only for Larry.
I want to put this pictures in the sidebar using text widgets but I don't want Larry to see your picture or you to see Larry's.

Thanks

juggledad Sep 13, 2010 07:55 AM

HTML Code:

<?php global $current_user;
get_currentuserinfo();
$who_is_user = $current_user->
user_login;

if ($who_is_user = 'admin')
  echo '<img src="http://yourdomain.com/wp-content/uploads/juggledad.jpg"  />' ;
elseif ($who_is_user = 'Larry') 
  echo '<img src="http://yourdomain.com/wp-content/uploads/larry.jpg"  />' ;
else
  echo "Hey, if you login, we can offer more info!";
?>


juggledad Sep 13, 2010 07:59 AM

you could even try this
HTML Code:

<?php global $current_user;
get_currentuserinfo();
$who_is_user = $current_user->
user_login;

if ($who_is_user)
  echo '<img src="http://yourdomain.com/wp-content/uploads/".$who_is_user.".jpg"  />' ;

else
  echo "Hey, if you login, we can offer more info!";
?>

then you would just have to have an image with the title of the users name.jpg

lmilesw Sep 13, 2010 08:35 AM

Or perhaps you could use a membership plugin such as s2Member to restrict access to certain areas.

thanos Sep 13, 2010 11:34 AM

I have tried s2Member but ended up using MemberWingX instead.
juggledad thanks for the above codes. This is a way of doing what I want but i will have to edit the code each time i have a new subscriber. I will try to automate the proccess by trying to create widget areas for each user.

Thanks

juggledad Sep 13, 2010 07:15 PM

Try my second idea, one widget, you just have to add an iimage for each user


All times are GMT -6. The time now is 07:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.