Automatically Add Tags Taxonomy in Post from Custom field’s value

I want to automatically add my ACF custom fields value as a tags when i publish/save the post.

First Tag:

My ACF Custom field’s id is: app_name

I want to add "Download Free app_name Latest Version" as a tags automatically after publishing the post.

Second Tag:

My ACF Custom field’s id is: app_dev

I want to add "Get app_name By app_dev from Here" as a tags automatically after publishing the post.

Warning: A non-numeric value encountered?

Hi everyone after transferring my site to another hosting I get this error: (php 7.4 on both hosts) "Warning: A non-numeric value encountered in /htdocs/ on line 159"

the code on line 159 is the following:

     $  discount = round (intval($  sale_price  / $  regular_price ) * floatval (100)); 

where am i wrong?

Thanks for help me

Finding Position of a Nested List By A Value Test

What I am looking for is an understanding of why what seems to me a straightforward extension of finding elements in lists does not extend (without returning error messages) to nested lists.

A couple of different syntaxes that return the position in flat lists:

test1 = {1, 2, 3, 4}; FirstPosition[test1, _?(# > 2 &)] FirstPosition[test1, n_ /; n > 2] 

In both cases the expected result of 3 is returned.

If I try what seems to me the logical way of specifying a value to test in a nested list, like:

test2 = {{1, 100}, {2, 200}, {3, 300}, {4, 400}}; FirstPosition[test2, _?(First[#] > 2 &)] FirstPosition[test2, n_ /; First[n] > 2] FirstPosition[test2, n_ /; n[[1]] > 2] 

They return the value (3) as I expect. But they also return similar error messages like:

First::normal: Nonatomic expression expected at position 1 in First[List] 

with a stack trace ending in:

FirstPosition[{{1, 100}, {2, 200}, {3, 300}, {4, 400}}, _?(First[#1] > 2 &)] 

I do not understand what the error is here, or how it can be avoided. I would like to understand so that I can perform similar tests on arbitrarily complex nested lists, using the regular indexing syntax to reference the values to be tested without getting error messages.

There is nothing special about using FirstPosition in this example, other functions like Position, etc. are equally relevant.

Woocommerce if use a specific gateway, then set the value [closed]

I want to add a filter or an action for the plugin, the purpose is to set the value to "0" if the order used "myCRED" gateway.

I found those 2 related filters of the plugin,

uap_filter_referral_amount uap_public_filter_on_referral_insert_amount_value 

actually, I am not sure which one should I use, but I tried both of the 2 filters, when checkout it shows internal error, I think the code may have some error, any one can help?

Here is the code I have tried:

function exclude_mycred_gateway( $  order ){     $  payment_title = $  order->get_payment_method_title();     if ( $  payment_title ) {         $  payment_title == "myCRED";         return "0";     } }  add_filter( 'uap_filter_referral_amount', 'exclude_mycred_gateway'); 

Why the UI text value is changing take affect only when returning back to the visual studio window and than back to the editor?

My guess is because I’m using OnValidate but is there another way to try to accomplish what I’m trying ?

The goal is use the drawn circle in one script information and use this information in another script.

For example the GameObject the draw circle script is attached to I want to get the Y position of that GameObject and assign the value to the other script specific variable in both Editor and Runtime modes.

This script draw a circle in this case around my player and I attached this script to a empty GameObject child of my player so I can change the circle height by changing the GameObject Y position :

using UnityEngine; using System.Collections; using System;  [ExecuteAlways] [RequireComponent(typeof(LineRenderer))] public class DrawRadiusAroundObject : MonoBehaviour {     [Range(1, 50)] public int segments = 50;     [Range(1, 5)] public float xRadius = 5;     [Range(1, 5)] public float yRadius = 5;     [Range(0.1f, 5f)] public float width = 0.1f;     public bool controlBothXradiusYradius = false;     public bool draw = true;      [SerializeField] private LineRenderer line;      private void Start()     {         if (!line) line = GetComponent<LineRenderer>();          CreatePoints();     }      //private void Update()     //{     //         //}      public void CreatePoints()     {         line.enabled = true;         line.widthMultiplier = width;         line.useWorldSpace = false;         line.widthMultiplier = width;         line.positionCount = segments + 1;          float x;         float y;          var angle = 20f;         var points = new Vector3[segments + 1];         for (int i = 0; i < segments + 1; i++)         {             x = Mathf.Sin(Mathf.Deg2Rad * angle) * xRadius;             y = Mathf.Cos(Mathf.Deg2Rad * angle) * yRadius;              points[i] = new Vector3(x, 0f, y);              angle += (380f / segments);         }          // it's way more efficient to do this in one go!         line.SetPositions(points);     }  #if UNITY_EDITOR     private float prevXRadius, prevYRadius;     private int prevSegments;     private float prevWidth;      private void OnValidate()     {         // Can't set up our line if the user hasn't connected it yet.         if (!line) line = GetComponent<LineRenderer>();         if (!line) return;          if (!draw)         {             // instead simply disable the component             line.enabled = false;         }         else         {             // Otherwise re-enable the component             // This will simply re-use the previously created points             line.enabled = true;              if (xRadius != prevXRadius || yRadius != prevYRadius || segments != prevSegments || width != prevWidth)             {                 CreatePoints();                  // Cache our most recently used values.                 prevXRadius = xRadius;                 prevYRadius = yRadius;                 prevSegments = segments;                 prevWidth = width;             }              if (controlBothXradiusYradius)             {                 yRadius = xRadius;             }         }     } #endif } 

The object with the drawn circle :

Drawn circle around the player

And this script is making an object the Target child to rotate around my player. I want by using the drawn circle information to set the rotating variables.

using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine;  [ExecuteAlways] public class SimpleRotate : MonoBehaviour {     public List<TextMeshProUGUI> uiText = new List<TextMeshProUGUI>();      public DrawRadiusAroundObject drawAround;      // Add this script to Cube(2)     [Header("Add your turret")]     public GameObject Turret;//to get the position in worldspace to which this gameObject will rotate around.      [Header("The axis by which it will rotate around")]     public Vector3 axis;//by which axis it will rotate. x,y or z.      [Header("Angle covered per update")]     public float angle; //or the speed of rotation.      public float upperLimit, lowerLimit, delay;// upperLimit & lowerLimit: heighest & lowest height;      private float height, prevHeight, time;//height:height it is trying to reach(randomly generated); prevHeight:stores last value of height;delay in radomness;       // Update is called once per frame     void Update()     {         //Gets the position of your 'Turret' and rotates this gameObject around it by the 'axis' provided at speed 'angle' in degrees per update          transform.RotateAround(Turret.transform.position, axis.normalized, angle);         time += Time.deltaTime;         //Sets value of 'height' randomly within 'upperLimit' & 'lowerLimit' after delay          if (time > delay)         {             prevHeight = height;             height = Random.Range(lowerLimit, upperLimit);             time = 0;         }         //Mathf.Lerp changes height from 'prevHeight' to 'height' gradually (smooth transition)           transform.position = new Vector3(transform.position.x, Mathf.Lerp(prevHeight, height, time), transform.position.z);          uiText[0].text = angle.ToString();         uiText[1].text = upperLimit.ToString();         uiText[2].text = lowerLimit.ToString();         uiText[3].text = delay.ToString();          upperLimit = drawAround.transform.position.y;     } } 

The object with the script that make Target object child to rotate around my player

Target is the basketball.

The basketball rotating around my player.

For example I tried to set the object Y position value on the Upper Limit variable in the SimpleRotate script.

Everything is getting update find in editor mode and runtime mode except the ui text.

First of all I’m not sure using [ExecuteAlways] in both scripts is the right way and second because I’m using OnValidate in the script that draw the circle the affecting on the variable upper limit is taking affect only when I validate by changing windows in the editor mode.

Get ACF value after update user using Ajax

I’ve updated some ACF fields in user section via an ajax call using update_field() fonction.

update_field('field_name', 'field_value', 'user_' . $  user_id); 

When i take a look in the admin panel, everything is fine, but in front, i don’t have any values. In order to get those values i need to manualy save/update user in the back office.

In my template i use :

get_field('field_name','user_'.$  user_id); 

Any tips or advice ?

Thx in advance

Updating column value across all SQL server versions

I have a simple table with 3 columns

Installed by – some login name

Installed date – Date when bunch of scripts were run with any changes as part of that package

Version – version number when release was done

I am thinking below.

UPDATE Tablename SET Version = '7.8.1' ; 

In case above is not the correct way, How should I correctly update the version # column when release is done say when some scripts are installed today, version # needs to be updated lets say 7.8.1. Also this needs to work across all versions of SQL server from 2012 to 2019

How to build a SQL query where certain fields can be null or have value?

I need to do a SQL query to a custom WordPress database table where certain columns are nullable. I wrote this static method:

    public static function does_name_exist( $  name ) {      global $  wpdb;      $  table = $  wpdb->prefix . self::DB_TABLE;      if ( is_string( $  name ) ) {         $  query = $  wpdb->prepare( "SELECT `id` FROM `$  table` WHERE `given_name` = %s", $  name );     } elseif ( is_array( $  name ) ) {         $  query = $  wpdb->prepare(             "SELECT `id` FROM `$  table` WHERE `name_prefix` = %s AND `given_name` = %s AND `additional_name` = %s AND `family_name` = %s AND `name_suffix` = %s",             empty( $  name['name_prefix'] ) ? null : $  name['name_prefix'],             empty( $  name['given_name'] ) ? null : $  name['given_name'],             empty( $  name['additional_name'] ) ? null : $  name['additional_name'],             empty( $  name['family_name'] ) ? null : $  name['family_name'],             empty( $  name['name_suffix'] ) ? null : $  name['name_suffix']         );     } else {         return false;     }      $  id = $  wpdb->get_var( $  query );      if ( null !== $  id ) {         return (int) $  id;     } else {         return false;     }  } 

The problem is when a value in $ name array is empty the query compare NULL with equal instead of IS operator.

Example of wrong SQL query:

SELECT * FROM `wp_recipients` WHERE `name_prefix` = NULL AND `given_name` = 'John' AND `additional_name` = NULL AND `family_name` = 'Smith' AND `name_suffix` = NULL  

Example of correct SQL query:

SELECT * FROM `wp_recipients` WHERE `name_prefix` IS NULL AND `given_name` = 'John' AND `additional_name` IS NULL AND `family_name` = 'Smith' AND `name_suffix` IS NULL 

How can I solve the problem?

How to link value pairs to formula

I got this formula rij= ri/2+ dri+ rj/2+ drj+ kij+ 10Log[ss/(1 lij)]

The values for Ri, Rj, Kij are frequency-dependent, so there are 21 different values ( 1 for each frequency ) How do I tell Mathematica the values so I don’t have to rewrite the calculation every time?

Can you help me get a Table, where I just Fill In my Values so that they connect to the Formula. Thanks.