Custom shortcodes – retrieve normal WP user data?
-
Hello mailpoets,
I tried my best to find a way to retrieve user data that is stored in the wp user profile. Lets take the simple case of “last_name”. Here is what i tried and the results i got:
$replacement = 'hallo';
shortcode [custom:name] returned hallo – so the shortcode as such works and is inserted!$replacement = $user_info->last_name;
returned [custom:name]$replacement = $user_info->user_last_name;
returned [custom:name]$replacement = get_userdata($user_info->user_last_name);
returned empty$replacement = get_userdata($user_info->last_name);
returned empty… trying to get user_info first by
$user_info = get_userdata($this->receiver->wpuser_id); $replacement = $user_info->last_name;
returned “Request error not JSON”
funny thing for me as a noob is: replacing in shortcode.php line 185
$replacement = $user_info->display_name;
with
$replacement = $user_info->last_name;
works for shortcode: [user:displayname]!I hope you can help me and others with a “user data” example 🙂
Thank you
Tobias
- The topic ‘Custom shortcodes – retrieve normal WP user data?’ is closed to new replies.