2015-11-28 143 views
0

我已經在我的wordpress網站上安裝了WPdeposit插件,它允許用戶存入賬戶餘額。我試圖在按頁面上的定位標記時操縱用戶餘額。wordpress插件WPdeposit,如何使用功能

在plugins目錄/模型/ user.php的有很多功能,我想在這一個IM感興趣:

/** 
* Update Regular balance to given amount (Will overwrite whatever value is in the db!) 
* 
* @param int $amount 
* @return boolean 
*/ 
public function updateRegularBalance($amount) { 
    if (floatval($amount)) { 
     return (bool) update_user_meta($this->_id, WPDEPOSIT_NAME.self::USER_AMOUNT, $amount); 
    } else { 
     throw new \Exception(__('Amount is not a number', WPDEPOSIT_NAME)); 
    } 
} 

當我嘗試調用這個函數來在頁面上的主題的index.php文件像這樣:

updateRegularBalance(5); 

但我收到此錯誤。 致命錯誤:調用未定義的函數updateRegularBalance()

有沒有辦法訪問這個函數的使用,所以我可以傳入我想要更新餘額的值?

+0

詢問插件頁面,但是你太早調用函數,你需要找到函數運行的鉤子,init通常是一個安全的下注 – David

回答

0
$class = new UserModel(); 
$class->updateRegularBalance(9999); 

它從來不是我試圖使用的函數,它是一種方法。