How can I set a country selected by default in the Country field?
This can be achieved by changing the default PHP code found in the Values area of the Country field to something like this:
//<code> $db = Joomla\CMS\Factory::getDBO(); $db->setQuery("SELECT name FROM #__rsmembership_countries WHERE name NOT LIKE 'France'"); return "France\n".implode("\n", $db->loadColumn()); //</code>
Where you should change France, throughout the above script, to the country of your choice. This code will place the chosen country on the top of the list.
If you don't want the selected country to be moved from its position, you can use the following code instead:
//<code> $db = \Joomla\CMS\Factory::getDbo(); $db->setQuery("SELECT name FROM #__rsmembership_countries"); $results = implode("\n", $db->loadColumn()); $results = str_replace('France', 'France[c]', $results); return $results; //</code>
12 persons found this article helpful.
You Should Also Read
Can I auto-populate custom fields ? |
Create membership custom fields |