Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Sidebars & Widgets »

New Widget Area named after logged user ID


  #1  
Old Sep 12, 2010, 06:29 AM
thanos
 
5 posts · Feb 2010
Athens, Greece
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
  #2  
Old Sep 13, 2010, 05:37 AM
lmilesw's Avatar
lmilesw
 
10,176 posts · Jul 2009
Central New York State USA
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.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #3  
Old Sep 13, 2010, 06:51 AM
thanos
 
5 posts · Feb 2010
Athens, Greece
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
  #4  
Old Sep 13, 2010, 07:13 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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";}
?>
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Sep 13, 2010, 07:38 AM
thanos
 
5 posts · Feb 2010
Athens, Greece
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
  #6  
Old Sep 13, 2010, 07:55 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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!";
?>
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #7  
Old Sep 13, 2010, 07:59 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #8  
Old Sep 13, 2010, 08:35 AM
lmilesw's Avatar
lmilesw
 
10,176 posts · Jul 2009
Central New York State USA
Or perhaps you could use a membership plugin such as s2Member to restrict access to certain areas.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #9  
Old Sep 13, 2010, 11:34 AM
thanos
 
5 posts · Feb 2010
Athens, Greece
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
  #10  
Old Sep 13, 2010, 07:15 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
Try my second idea, one widget, you just have to add an iimage for each user
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to only display Page menu to logged in users? Thomas Page & Category Menu Bars 7 Jul 5, 2010 01:54 AM
[SOLVED] Comments link not showing when not logged in sargemarcori Forum How-To 1 Jun 2, 2010 03:27 PM
Positioning widget onto logo area creates extra spacing in the overall header area cab262 Header configuration & styling 1 May 20, 2010 01:14 PM
Why doesn't Atahualpa use an externally named CSS file? Elms123 Header configuration & styling 2 Mar 22, 2010 04:45 PM
[SOLVED] Help ! Links broken in widget in new widget area mikecnwa Sidebars & Widgets 4 Sep 16, 2009 01:56 PM


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


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