2016-04-30 100 views
0

當前用戶ID我有嵌入我的WordPress頁面上的以下網址與下面的代碼的iframe:嵌入式iframe網址包括在WordPress

<iframe src="https://cpalead.com/mobile/locker/?pub=195930&gateid=985632&subid=$user" height="100%" frameborder="0" name="iframetarget" id="iframetarget"></iframe> 

我的頁面模板有定義$用戶參數如下:

$user = get_current_user_id();

然而,當我的頁面加載的iframe的網址來源是這樣的:

https://cpalead.com/mobile/locker/?pub=195930&gateid=985632&subid=$user 

它不通過$用戶變量的iframe源URL ....像這樣,說用戶1登錄,源地址應該是:

https://cpalead.com/mobile/locker/?pub=195930&gateid=985632&subid=1 

我有一點點調試這PHP:

echo "you are user $user";

其確實顯示正確的用戶。

我在做什麼錯?

+0

普萊舍試試這個:https://cpalead.com/mobile/locker/?pub= 195930&gateid = 985632&subid = <?php echo $ user; ?> –

+1

'var_dump($ user)'說什麼?當您提出有關錯誤的問題時,***總是***,發佈錯誤日誌。要啓用錯誤報告給您的php代碼附加'error_reporting(E_ALL); ini_set('display_errors','1');'在腳本的頂部,它返回什麼? –

+0

你的問題很混亂。該網址格式不正確,或者是網址中的用戶ID,但在iframe中不可用? – RST

回答

0

您正在使用它作爲文本。你應該echo變量

<iframe src="https://cpalead.com/mobile/locker/?pub=195930&gateid=985632&subid=<?php echo $user; ?>" height="100%" frameborder="0" name="iframetarget" id="iframetarget"></iframe> 

的值,那麼iframe裏面,你可以使用 $_GET['subid']使用的值

+0

我這樣做,但鏈接源現在是這樣的:https://cpalead.com/mobile/locker/?pub=195930&gateid=985632&subid= PHP沒有被編譯......不知道,我正在使用visual composer with wordpress –

+0

是你的.php文件中的代碼?顯示更多代碼 – RST

+0

不得不爲WordPress創建一個新的頁面模板,以便更好地控制我的iframe。它理解echo $ user並且工作,謝謝你們! –