Write a PHP Code Snippet for a Wordpress Page

Job ID: 33205426

Budget: £10 – £20 GBP

HI there,

I have a wordpress membership site which has a plugin so people can refer other members.

On one page, I need a php code snippet to display this link, from an external affiliate program, as default:

https://www.myleadgensecret.com/?rid=29378

But if the member's referrer has submitted a different affiliate code, e.g 33333 then it should display:

https://www.myleadgensecret.com/?rid=33333

At the moment, all I can do is fetch the referrer's id, and the code of the logged in user.

<?php


$current_user = wp_get_current_user();

echo 'Referrers ID: ' . $current_user->wrc_referrer_id . '<br />';
echo 'MLGSid: ' . $current_user->MLGSid . '<br />';
?>


"wrc_referrer_id" is the id for the person who referred that member to my website, "MLGSid" is the logged in users code for the external program.

So basically I need a bit of code that goes like this:

1. Fetch the user id of the referrer wrc_referrer_id
2. Use that to look up the MLGSid of wrc_referrer_id
3. Display that at the end of the link, else 29378 if that field is empty.


I hope I’ve managed to explain my issue, can you help?

Many thanks,

Dan
Related categories: PHP WordPress phpMyAdmin