help for PHP Script

  • Cousins de la Marquise
  • Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 10 months ago - 6 years 10 months ago #115131 by Cousins de la Marquise
help for PHP Script was created by Cousins de la Marquise
Hi,

Firstly sorry for my bad english. I would wish to update a particular field value in a Community Builder table after renewal payment validation. My table name is #_comprofiler and the field name is cb_cotisation. I've made tests but they don't seem play well. Anybody could check syntax of my srcipt that I have tape on PHP Script Settings of my plan, in Scription Active Script field.
Code:
$db = JFactory::getDbo(); $query = $db->getQuery(true); // Fields to update. $fields = array( $db->quoteName('cb_cotisation') . ' = ' . $db->quote('2019'), ); // Conditions for which records should be updated. $conditions = array( $db->quoteName('cb_numeroadherant') . ' = ' . $row->osm_Numero_adherent, ); $query->update($db->quoteName('#__comprofiler'))->set($fields)->where($conditions); $db->setQuery($query); $result = $db->execute();

Thanks a lot.
Last edit: 6 years 10 months ago by Cousins de la Marquise.

Please Log in or Create an account to join the conversation.

More
6 years 10 months ago #115137 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic help for PHP Script
Hi

The only thing wrong is $row object doesn't contain osm_Numero_adherent (this is a custom field, so it's value is stored in different database table)

The easiest way to do make this script works is:

1. Login to administrator area of your site

2. Access to this URL:

domain.com/administrator/index.php?optio...d_id=ID_OF_THE_FIELD

- domain.com/administrator must be replaced with administrator URL of your site
- ID_OF_THE_FIELD must be replaced with id of the custom field osm_Numero_adherent

When you do that, the system will create a new field osm_Numero_adherent in table #__osmembership_subscribers, store value of that field into the table and you can use it in the script

Try to do that and check it again, it should work as expected

Tuan

Please Log in or Create an account to join the conversation.