WordPress.org

Ready to get started?Download WordPress

Forums

User Registration Aide
[resolved] How do you echo a field's value? (2 posts)

  1. oomskaap
    Member
    Posted 1 year ago #

    I want to echo a field's value on my home page, so the user can view it, but how do i retrieve the data to show it in the template file.

    http://wordpress.org/extend/plugins/user-registration-aide/

  2. bnovotny
    Member
    Plugin Author

    Posted 1 year ago #

    There are several ways, you can register a shortcode in the main user-registration-aide.php and add a function that would display the field and then add the shortcode to the template, something like:

    function addmyshortcode (){
    $current_user = wp_get_current_user();
    $username = $current_user->user_login;
    $first_name = $current_user->first_name;
    $last_name = $current_user->last_name;
    $display_name = $current_user->display_name;
    echo 'hello ' . $first_name . ' ' . $last_name;

    }

    add_shortcode( 'myshortcode', 'addmyshortcode' );

    Something along those lines to extract the user data you want to display, then add the [myshortcode] to the template, or you could try to add the code itself right to the template, however I am not quite sure if that wil work or not, and it is not the best idea. I am working on an update which will be released soon and may be able to add a feature like that in it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.