admin管理员组

文章数量:1420151

I made a wordpress faucet site using some plugins, and I would like to make it a little better.

I would like to make a referral link, so when it is /?r=Your-Address, I would like that the part Your-Address changes from user to user, so it would put the users litecoin address from the profile in the referral link, instead of saying your address.

How could I do this?

I made a wordpress faucet site using some plugins, and I would like to make it a little better.

I would like to make a referral link, so when it is http://free-liteco.in/?r=Your-Address, I would like that the part Your-Address changes from user to user, so it would put the users litecoin address from the profile in the referral link, instead of saying your address.

How could I do this?

Share Improve this question edited Jul 15, 2019 at 6:43 nmr 4,5672 gold badges17 silver badges25 bronze badges asked Jul 15, 2019 at 4:03 davis90davis90 1
Add a comment  | 

1 Answer 1

Reset to default 0

Have a look at the get_user_meta function.

Assuming the litecoin address in the user's profile is stored as user meta, with the key of litecoin_address you can output the link like so:-

$litecoin_address = get_user_meta( get_current_user_id(), 'litecoin_address', true );

if( !empty( $litecoin_address ) ){
    // maybe do some additional sanitation of the litecoin address here
    $link = sprintf( 'http://free-liteco.in/?r=%s', $litecoin_address );
    echo $link;
} else {
    echo 'Please login and complete the litecoin address in your profile';
}

本文标签: shortcodeHow to create custom variables in wordpress