What function can I use to determine new user registration?

I have created a function that sends a message to members. I would like this function to fire only if the user has just registered.

function send_message_to_new_member() {     // If user has just created account    if( is_new_user() ) { //is_new_user() doesn't exist, so how can I go about this?            // Do something     } } add_action( 'woocommerce_order_status_completed', 'send_message_to_new_member', 2 ); 

Registration will take place at the Woocommerce checkout… not sure is the method of registration is different there compared to standard WordPress registration?

How to create a postgres function that returns a value

I am trying to move some of my web app logic into postgres functions. But I am hitting some errors while creating a very basic insert function.

This is the function that I am trying to create;

CREATE OR REPLACE FUNCTION create_user(IN email EMAIL, password TEXT, thumb TEXT) RETURNS text AS  $  BODY$   BEGIN    insert into users (unqid, thumb, email, password)     values (gen_random_uuid(), thumb, email, password)    returning unqid ; END; $  BODY$     LANGUAGE plpgsql   VOLATILE 

I am trying to get the function to return the uuid of the item if the insert is successful. And I am calling it like this;

select * from create_user('newuser@mail.com', 'passpopcorn', 'thumbelinaurl'); 

Getting this error;

SQL Error [42601]: ERROR: query has no destination for result data   Where: PL/pgSQL function create_user(email,text,text) line 3 at SQL statement 

From my googling it sounds like this error comes up when you don’t have a return statement in the query. But in my Insert query, I do have a returning statement.

Extra question; for simple insert statements (like this one here, or one with a couple of select followed by an insert), would functions be a better bet or procedures?

“Total” function for a Boolean expression

I have a very long vector of the form

{a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4,      a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4,      a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4, ...} 

(here I just repeated the elements for simplicity, but in general, each element is different). And I want to transform it into a Boolean expression where Plus->Or and Times->And.

What is the fastest way to do it? At the moment, I use Replace, but it’s really slow when the expression is bigger. Here the simpler example takes 0.000034 seconds:

RepeatedTiming[{a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4,             a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4,             a1 a2 a3 a4 + b1 b2 b3 b4 + c1 c2 c3 c4 + d1 d2 d3 d4 + e1 e2 e3 e4} /. {Times -> And} /. {Plus -> Or}] 

Also, is there an equivalent of the Total function for Boolean expressions?

How to reconstruct a complicated built-in function (e.g. for modification or use in a version that does not have it yet)

Is it possible to extract the definitions for a built-in function to reconstruct a similar user defined function. This would be useful to port new mathematica functionality to older versions or to create modified versions of built-in functions.

I found that

Needs["GeneralUtilities`"] PrintDefinitions[symbol]; 

could get us close (see https://mathematica.stackexchange.com/a/78898/45020) but it would still be quite a job to reconstruct the full function including all of its dependencies from there. Have there been any automated attempts to try this kind of thing?

As an example I would be very interesting in reconstructing ExternalEvaluate (or if that is too ambitious to reconstruct only the part that converts Mathematica arguments supplied with "Arguments"->{args} to python expressions in the case that we ExternalEvaluate using a python session.)

(I hope this type of question is not frowned upon in light of copyright issues. I would just like to deal with incompatibility issues between different (Licensed) versions of Mathematica.)

OptionValue doesn’t work if a local variable has the same name as the function itself

The following innocent-looking code results in error.

Options[add] = {number -> 1}; add[x_, OptionsPattern[]] := Module[{add},    x + OptionValue[number] ]; add[1] 

The error is

OptionValue::optnf: Option name number not found in defaults for add$  2832. 

What triggers the error is the fact that a local variable declared by Module has the same name as the function, add. (For simplicity, I’ve shown an example where this local variable isn’t actually used in the code, but this doesn’t make a difference.)

Is this a bug in Mathematica, or some known quirk of OptionValue[]?

PostgreSQL backend function after an elog(ERROR) had been issued

Getting this weird issue one time per postgresSql session. Like if I run this query first time, will return with below message but if I rerun the same, it works fine.

DEBUG: An attempt was made to call a PostgreSQL backend function after an elog(ERROR) had been issued ERROR: org.glassfish.jersey.internal.ServiceConfigurationError: org.glassfish.jersey.internal.inject.InjectionManagerFactory: : java.io.IOException: An attempt was made to call a PostgreSQL backend function after an elog(ERROR) had been issued.

WordPress: Call to undefined function wp_embed_register_handler()

I have a WordPress website that is still under development. I was working on this website till end of Feb, 2021 and hold all works due to COVID crises. Till that date, website was working. Now I have resumed my work and just looking into website. But now, website is throwing an error "Fatal error: Uncaught Error: Call to undefined function wp_embed_register_handler()"

I have also crossed the file "wp-includes/embed.php" file in which this function exists and function is already defined before calling it. You can see attached screenshot of whole error tracing.

enter image description here

I am not getting this error on all pages but almost every pages. I am not able to understand why I am getting this error even I have not touched anything on website from last 3-4 months. And it was working fine when I was working last.

Can someone please help on this? I am not very experienced in WordPress but have intermediate knowledge.

Thanks in Advance

Parametric plot of a function which cannot be explicitly calculated

I wish to plot a function, but I run into a problem and I cannot find similar questions here. A simplified version of plot is represented by

ParametricPlot[{g,f[x,y]}, {x,a,b},{y,c,d}]

f is quite a tricky expression and cannot be explicitly calculated for unknown x and y. Hence this plot does not work, as I believe Mathematica first explicitly calculates f[x,y] and then thereafter substitutes x and y in order to plot this. However, how can I do this such that f[x,y] substitutes the explicit values for x and y into f, as then the function can be calculated? For example, f[1,2] works absolutely fine, f[x,y] is the problem.


My code:

 cc = 0.4;  cD = 0.1;  r = 10.2;  Nstar = Floor[r];  rhos1[N_] := (1 - N/r)*Lambda^N*      Exp[eps]*Delta; rhos2[N_] := (1 - N/r)*(Lambda*Exp[g])^N*      Exp[eps]*Delta*Exp[g*Nstar]  rho = Sum[rhos1[n], {n, 1, Nstar}] +     Sum[rhos2[n], {n, Nstar + 1, Infinity}]; phi = Sum[n*rhos1[n], {n, 1, Nstar}] +     Sum[n*rhos2[n], {n, Nstar + 1, Infinity}];   phi3[Delta_] :=         Sum[n*(1 - n/r)*\[CapitalLambda]^n*          Exp[\[Epsilon]]*Delta, {n, 1, Nstar}] +         Sum[n*(1 - n/r)*(Lambda*Exp[g])^n*          Exp[eps]*Delta*Exp[g*Nstar], {n, Nstar + 1,           Infinity}];  RhoDivided3 = Simplify[rho/Delta]  h1 = cD/(RhoDivided3 + Exp[g]);   f[eps1_, g1_] := Apply[List, Reduce[cc ==    ReplaceAll[phi3[h1] + Lambda*      Exp[eps], {eps -> eps1,      g -> g1}] && Lambda > 0 && Lambda <    0.99999, Lambda], {0, 1}][[2]]  Plot[ReplaceAll[phi/rho, {Lambda -> f[-2, g],           eps -> -2}], {g, -30, -10}] 

Therefore f is obtained by solving a very complex equation for Lambda, and so cannot be determined as a function of epsilon and g, as explicit values are required.