Community Support Forums — WordPress® ( Users Helping Users ) — 2010-10-27T02:22:11-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=1094 2010-10-27T02:22:11-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1094&p=4276#p4276 <![CDATA[Re: Can't Use Wordpress Function]]>
arwyl wrote:
Well, you haven't really assigned a value to the $current_user variable, so the array is empty.
The second line of your code, right after the php tag, should read:
Code:
$current_user=wp_get_current_user();

(This is exemplified in the commented bit of your code snippet, btw.)

User "arwyl", forum rank updated to:
Experienced User

Statistics: Posted by Jason Caldwell — October 27th, 2010, 2:22 am


]]>
2010-10-26T23:49:51-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1094&p=4267#p4267 <![CDATA[Re: Can't Use Wordpress Function]]> Statistics: Posted by Dr Dave — October 26th, 2010, 11:49 pm


]]>
2010-10-26T20:50:30-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1094&p=4263#p4263 <![CDATA[Re: Can't Use Wordpress Function]]>
Finally dawned on me what arwyl was telling me. This works ...

Code:
  <?php
       $current_user = wp_get_current_user();
        echo 'Username: ' . $current_user->user_login . '<br />';
        echo 'User email: ' . $current_user->user_email . '<br />';
        echo 'User level: ' . $current_user->user_level . '<br />';
        echo 'User first name: ' . $current_user->user_firstname . '<br />';
        echo 'User last name: ' . $current_user->user_lastname . '<br />';
        echo 'User display name: ' . $current_user->display_name . '<br />';
        echo 'User ID: ' . $current_user->ID . '<br />';
    ?>


I am sort of familiar with this function, having experimented with it (but not really used it) before. Was wondering if it worked in the protected area, so I started there.

Statistics: Posted by KirkWard — October 26th, 2010, 8:50 pm


]]>
2010-10-26T20:24:15-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1094&p=4262#p4262 <![CDATA[Re: Can't Use Wordpress Function]]>
s2member doesn't block the function, it transforms it. Once set in motion, s2m creates its own set of API Constants you can use to do virtually anything.

Have you looked at the plugin backend? Just go to s2member --> API / Scripting and you'll find all sorts of goodies.

Jason's put a ton of cheats in there.

I'd offer you more, but I'm the type who has to read --> click a mouse --> read more --> type some, and then cross my fingers;-)

Dave

Statistics: Posted by Dr Dave — October 26th, 2010, 8:24 pm


]]>
2010-10-26T19:05:44-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1094&p=4260#p4260 <![CDATA[Re: Can't Use Wordpress Function]]> Statistics: Posted by KirkWard — October 26th, 2010, 7:05 pm


]]>
2010-10-26T18:33:40-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1094&p=4257#p4257 <![CDATA[Re: Can't Use Wordpress Function]]>
The second line of your code, right after the php tag, should read:

Code:
$current_user=wp_get_current_user();


(This is exemplified in the commented bit of your code snippet, btw.)

Statistics: Posted by arwyl — October 26th, 2010, 6:33 pm


]]>
2010-10-26T13:44:48-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1094&p=4252#p4252 <![CDATA[Can't Use Wordpress Function]]>
Code:
wp_get_current_user()

and it did not return data from the Wordpress database for the current logged in member.

Why come?

Does s2 block the function?

I used as follows, cut and pasted from the WP function reference ...
Code:
<?php
    wp_get_current_user();
    /**
     * @example Safe usage: $current_user = wp_get_current_user();
     * if ( !($current_user instanceof WP_User) )
     *     return;
     */
    echo 'Username: ' . $current_user->user_login . '<br />';
    echo 'User email: ' . $current_user->user_email . '<br />';
    echo 'User level: ' . $current_user->user_level . '<br />';
    echo 'User first name: ' . $current_user->user_firstname . '<br />';
    echo 'User last name: ' . $current_user->user_lastname . '<br />';
    echo 'User display name: ' . $current_user->display_name . '<br />';
    echo 'User ID: ' . $current_user->ID . '<br />';
?>

I got the text echo, but not the array data.

Statistics: Posted by KirkWard — October 26th, 2010, 1:44 pm


]]>