Create iframe with dynamic URL: efficient way to use user data
<p>First time posting a question here. I'm definitely not a coding expert, I've learned some HTML and CSS through Google, StackOverflow, and a lot of trial and error, but this question seems to be a PHP question, and I know next to nothing about PHP. </p>
<p>I'm creating a subscription WordPress website and I need to create an iframe with a dynamic src value. </p>
<p>The first part of the src value is the same for every user (e.g. https://app.example.com/autoin/), then it should be completed with a unique code assigned to each user. The code is in a field in the user's profile. I'm currently using the second address line. The id or name of this field is address-two. </p>
<p>The closest code I found that worked was the code below, which I added directly to the page I would use, using WPBakery's raw HTML box. </p>
<pre class="brush:php;toolbar:false;"><?php
$current_user = wp_get_current_user();
if($current_user) {
?>
<iframe class="metricool-iframe" src="https://app.example.com/autoin/<?php echo $current_user->address-two; ?>>
</iframe>
<?php
}
?></pre>
<p>When I check the page source in Chrome, I can see that the URL is still <code>https://app.example.com/autoin/<?php echo $current_user->address- two; ?></code>
So, it doesn't actually work. </p>
<p>Excuse me, is there anything I can do to improve the above code? Or is there any other way? Please keep in mind that I'm completely new to this :P</p>
<p>Thanks in advance! </p>
<p>Yeah. </p>