• Resolved foots

    (@foots)


    Hi,

    I’m trying to export the author data. I used your snippet for showing the Author Name from ID, I’d like to be able to pull the author info from the ID.

    I’ve tried the following with no success:
    function my_get_author( $user_id ) {
    $user = get_user_by( ‘id’, $user_id );
    return $user->display_name;
    return $user->user_email;
    }
    function my_author_info( $user_info ) {
    $user_info = get_userdata(1);
    echo ‘Username: ‘ . $user_info->user_login . “\n”;
    echo ‘User roles: ‘ . implode(‘, ‘, $user_info->roles) . “\n”;

    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @foots

    Your functions need to return the data, and you can only return data once. Here are edited versions of your functions that should work fine:

    function my_get_author( $user_id ) {
    	$user = get_user_by( 'id', $user_id );
    	$return = $user->display_name . "\n";
    	$return .= $user->user_email . "\n";
    	return $return;
    }
    
    function my_author_info( $user_info ) {
    	$user_info = get_userdata( $user_info );
    	$return = "Username: " . $user_info->user_login . "\n";
    	$return .= "User roles: " . implode(', ', $user_info->roles) . "\n";
    	return $return;
    }
    Plugin Author WP All Import

    (@wpallimport)

    Hi @foots,

    I’m going to mark this as resolved. Go ahead and reply if you’re still having problems.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Export Author Info’ is closed to new replies.