Add record to ACF Field group programatically - advanced-custom-fields

I've created a Field Group using ACF. All the fields are simple text fields. I now want some way to create a function that can add a record using php code. How is it possible to do that?

You can use:
update_field( 'my_field', 'my_value', $post_id );
Here is the source: https://www.advancedcustomfields.com/resources/update_field/

Related

Custom Input Field when select shipping method on frontend - Magento1

I want to create a Custom Shipping Method on Checkout Page and when customer will select that Shipping Method, it should display a new text field and allows customer to enter in the text field. That text field value should be shown everywhere in the admin, emails etc.
Can anyone please me in this or any right direction to achieve this.
Any help will be really appreciated.
Thank you
You need to create a module. Here you have an easy example to create a new shipping method:
https://inchoo.net/magento/custom-shipping-method-in-magento/
To add the field you told, you should add a new column to database. Depending on the content of this field and how you will retrieve this information you could add this column to sales_flat_order or sales_flat_shipment.
Here you have an example to do this:
https://magento.stackexchange.com/questions/9751/adding-custom-fields-to-sales-flat-order
Adding this feature to the custom shipping method should be enough.
Hope it helps. Regards.

Function field for many2many odoo 8

I need to declare a many2many field as functional field. I tried below code but doesn't create any relational table in database.
def _get_function(self,cr,uid,ids,name,args,context=None):
resp={}
for data in self.browse(cr,uid,ids):
print'inside get Function'
return resp
'many2many_ids': fields.function(_get_function, method=True, relation="table.table1", obj='table1_table2_rel', type="many2many" , string="Many2Many")
Now data saved in form view, but i can't access that values in another function. like,
for data in self.browse(cr,uid,ids):
print'many2many_ids',data.many2many_ids
Here print no values.
How can i do that?
if you want the field to be stored use "store" option.
Also, you might consider using new API on v8. Check "Computed field" in official docs https://www.odoo.com/documentation/8.0/reference/orm.html

Admin - Add new post - hook to display some custom input fields

i have a custom post type
this post type needs some fields to be inserted into a custom MySQL table (wp_my_custom_table) where i store some relations IDs with other products and a number to sort them
i don't know how to put these input fields them after the textarea. I know how to insert them at "save_post" action hook.
these are not registered as "custom fields", are just a few input fields needed for each post type like this
The tag doesn't work, so i put the code that i have tried as image:
I have found, there is a hook "edit_form_after_editor".

Inserting multiple selected dropdown values into a single column

Iam having a form which contaings of name,id etc..in this form iam getting dropdown from the same table only some ids here iam selecting multiple values and that should be inserted into db but only one value is inserting into the table remaining is not inserting can any one help me regarding this.
Model:
$data=array(
'first_name'=>$this->input->post('first_name'),
'exam_id'=>$this->input->post('exam_id'),
);
$this->db->insert('table',$data);
This is my dropdown
$this->table = 'table';
$exam = $this->dropdown('exam_id','examr_id');
return $exam;
This is my view:
$exam['']='--Select --';
$exam_id="id='exam_id' ";
if($this->input->post('exam_id')) $selected=$this->input->post('exam_id');else $selected='';
echo form_multiselect('exam_id',$exam,$selected,$exam_id);?>
any one help me it will be more helpfull for me
When you select multiple values and check that selected value pass in your url using GET or POST method. And than split your requested data using implode function. and save into database.

Get term id of current taxonomy in wordpress

I am trying to create a function which adds additional custom data fields to my taxonomy pages, I have found this plugin which add this capability.
Now I can get the saving the custom data works fine.. however trying to get the metadata on edit form pages is another story..
I've followed the documentation which says to use the following line..
get_term_meta($term_id, $key, $single)
However I am unable to get this to work.. I have to manually enter the term_id like so..
$term_meta = get_term_meta('36', '', true);
.. in order for it to work.
Can someone tell me what code I would need for php get the term_id?
You can use this function to do the debug
$term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
print_r ($term);
Thanks
yes true.
$idObj = get_category_by_slug(post_type);
$id1 = $idObj->term_id;
If you are using any WordPress inbuilt function, then you need write the objname->subkey.
Okay so I found the problem
I had to use $term_id->term_id instead of just $term_id