How to transform WordPress user role code to WP shortcode?

You can add a parameter to your shortcode function and use this value to check if the user is allowed to view.

function func_check_user_role( $atts, $content = null ) {
    $user = wp_get_current_user();
    $user_role = $atts('role');
    $allowed_roles = ();
    array_push($allowed_roles , $user_role);

if ( is_user_logged_in() && array_intersect($allowed_roles, $user->roles ) ) {
      return $content;
 } else {
    return '';
}

}
add_shortcode( 'check-user-role', 'userRoleCheck' );

And your shortcode looks like:

(check-user-role role="subscriber") Your content (/check-user-role)

So the $atts are your attributes, the $content is your post content:

Shortcodes with Parameters

You save the value inside of your $user_role variable and check, if your user is logged in and has the role in the user object (you got that in your $user). If this is true you return the content. If not true, there is nothing to be returned or maybe a string like “you are not allowed to view this content”.

Hope this helps!

partial differential equations – Solve $u_t$ + -$u__xx$ + $xu$ using Fourier Transform

Thanks for contributing an answer to Mathematics Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

networking – Unity Mirror Network Transform not working

I am having an issue with Mirror’s network transform component in unity. Players cannot see each other move, and in the inspector window only the host’s player moves (this is not updated to the connected player though). In the inspector window you see a sphere moving and facing in the direction of the connected player (I did not program this so it must be Unity trying to tell me something) as per the picture below. Notice the grey ball moving in the left screen (The grey ball in the right screen is just a placeholder for the player's hand, ignore that)

Any help is much appreciated as there doesn’t seem to be anybody that I can find online with a similar problem.

Thank you!

photoshop – How to transform a picture with reference points on another picture?

I’m not sure about the scale difference. I’ve never tried that. But Photoshop’s PhotoMerge feature, which is used to create panoramic images from multiple smaller images is designed to do the rest of what you want to do.

If it can handle the different scale, all you would need to do is load the two images, then call up the function from File>Automation>PhotoMerge (menus may vary by version). It will give you a number of options to choose from and you may need to try different ones to see which works best for your specific images.

When you run the function, it will create a new image, using your two originals as layers in the new one, and matching and aligning them as much as it can, then masking out the layers to reveal one composite image. In doing so, it will twist and turn the images in the way you describe in order to make the major features of the images align.

You then have the option of doing whatever you want with those layers. Clear the masks and you will have two complete images. One or both may have been altered to suit, but they will align with each other, which seems to be your goal.

That is, IF it can handle the size difference.

dataset – How to efficiently transform a list of with entries of form {row_name, column_name, value} to a 2×2 table with the values?

I have a list imported from a CSV file of the form

data = {{row1, column1, value11}, {row2, column1, value21},{row1, column2, value12}, {row2, column2, value22},...,{rowi, columnj, valueij},...}

where the entries are not necessarily ordered, and the number of entries may be something like 100 to 500.

I would like to transform this to a table like

data == {{value11, value12}, {value21, value22}, ...,{valuei1,...,valueij,...},...}

where row i has values corresponding to rowi and column j has values corresponding to columnj.

It is trivial to do so manually in an inefficient way, but is there perhaps a specialized Mathematica function for this or a recommendable method?

How to calculate the inverse Fourier transform and undo things like HeavisideTheta (so the function looks exactly like the original notation)

My question consists of two parts (please check everything for errors):

The Fourier transform of

FourierTransform(Exp(-a Abs(t)), t, (Omega), 
 FourierParameters -> {1, -1})=(2 a)/(a^2 + (Omega)^2)

That is the correct answer.

1. How is the inverse Fourier transformation carried out correctly?

InverseFourierTransform(2 a/((a^2) + ((Omega)^2)), (Omega), t, 
 Assumptions -> a > 0 , FourierParameters -> {1, -1})=E^(a t) HeavisideTheta(-t) + E^(-a t) HeavisideTheta(t)

is it right?

  1. How to display the Inverse Fourier transform without HeavisideTheta? (or anything else that distinguishes the answer from the original function) so that the answer looks like the initial theoretical notation: Exp (-a Abs (t)).

Thanks a lot

Drawing – How do you draw the amplitude and phase spectrum of a Fourier transform in this specific pattern?

I'll show the easy way, then the hard way.

Easy way

Because the Fourier transform is the Laplace transform if it is real s is zero, then you can use BodePlot

ft = FourierTransform(Exp(-a t) UnitStep(t), t, w, FourierParameters -> {1, -1});

Mathematica graphics

ft = ft /. (I*w) -> s

Mathematica graphics

BodePlot(TransferFunctionModel((ft /. a -> 1), s))

Mathematica graphics

This way you can improve the plot

ft = FourierTransform(Exp(-a t) UnitStep(t), t, w, FourierParameters -> {1, -1})
ft = ft /. (I*w) -> s    
tf = TransferFunctionModel((ft /. a -> 1), s);
BodePlot(tf, GridLines -> Automatic, ImageSize -> 400,
 FrameLabel -> {{{"magnitude (db)", None}, {None, "Bode plot"}},
   {{"phase(deg)", None}, {"Frequency (rad/sec)", None}}},
 ScalingFunctions -> {{"Log10", "dB"}, {"Log10", "Degree"}}, 
 BaseStyle -> 14)

Mathematica graphics

Hard way

ft = FourierTransform(Exp(-a t) UnitStep(t), t, w, FourierParameters -> {1, -1});
LogLinearPlot(20*Log10(Abs((ft /. a -> 1))), {w, 0, 10})

Mathematica graphics

 LogLinearPlot(Arg((ft /. a -> 1))*180/Pi, {w, 0, 10})

Mathematica graphics

Extra credit

Here is a manipulation

Manipulate(
 Module({ft, t, s, w, tf, a0},
  ft = FourierTransform(Exp(-a0 t) UnitStep(t), t, w, 
    FourierParameters -> {1, -1});
  ft = ft /. (I*w) -> s;
  tf = TransferFunctionModel((ft /. a0 -> a), s);
  BodePlot(tf, GridLines -> Automatic, ImageSize -> 400,
   FrameLabel -> {{{"magnitude (db)", None}, {None, "Bode plot"}},
     {{"phase(deg)", None}, {"Frequency (rad/sec)", None}}},
   ScalingFunctions -> {{"Log10", "dB"}, {"Log10", "Degree"}}, 
   BaseStyle -> 14)
  ),
 {{a, 1, "a"}, .1, 10, .1, Appearance -> "Labeled"},
 ContinuousAction -> False,
 TrackedSymbols :> {a}
 )

Mathematica graphics

Google Sheets – Transform Table: Get N top results for each row and replace them with the header value

I have a table with names and countries as columns / rows:

Enter the image description here

Goal: Sort each line by the N highest (or lowest) values, and then replace the values ​​with the appropriate header names, such as B .:
Enter the image description here

I found a transpose version that does the job, but I don't really want to transpose 🙂

=query(sort(TRANSPOSE(A22:H22),transpose(A23:H23),FALSE),"limit 4")

dnd 5e – Can you use the shape change spell to transform yourself into a unique or named creature?

Inspired by this comment on an answer from me, I now wonder how exactly Change of shape works. The magic says (emphasis from me):

They take the form of another creature for the duration. The new shape can be of any creature with a challenge rating that is your level or lower. The creature cannot be a construct or undead, and You must have seen the type of creature at least once. They turn into an average example of this creature, one without grade levels or the spellcasting feature. (…)

The spell turns you into an "average example" of the selected creature. But you must have seen the "kind" of the creature at least once. So can you transform yourself into a unique or named creature where the "average example" is basically one thing and the only "kind" of creature is similar to that creature?

Some examples of unique / named creatures would be Titivilus, Yan-C-Bin, Kiril Stoyanovich or Ahmaergo. Humans / creatures where only one of them exists.


A somewhat related question:

Solve the heat / diffusion equation with the Fourier transform

I got stuck downstairs. In particular, I solved the PDE, but it's the initial conditions that confuse me. My previous solution is: (I use capital for functions in the Fourier range and I use z rather than $ omega $ how the question uses z):

$$
U (z, t) = F (z) e ^ {( beta – frac { alpha ^ 2 z ^ 2} {2}) t}
$$

Where $ F (z) $ is a post-integration function. Basically what confuses me now is how I calculate it $ F (z) $?

In particular, I do that. If $ u (x, 0) = g (x) $ then $ U (z, 0) = G_f (z) $ Where $ G_f $ is the G (z) with $ wedge $ about that. Then what is? $ sigma $? I have to train $ sigma $ as a function of $ alpha $? Or is $ sigma $ separate.

Below is a screenshot of the problem.

question