Hot answers tagged

4

You can use wp_localize_script() to pass php variables to javascript. You create an array in php and then pass it to the function as the third parameter. It will come through as an object you name with the second parameter. First, register the script. wp_register_script( 'custom-name-js', plugins_url( 'assets/custom-js.php', __FILE__ ) ); Second, build ...


2

The direct answer to the question "Is there a way to get 3+ dimensional array from a single MySql command" would be yes, sort of - WordPress routinely stores and retrieves multidimensional data from MySQL rows by serialize()ing and unserialize()ing structured data to/from a string format, so it's certainly possible using WordPress's database interaction ...


2

I mentioned in a comment how it's important to debug your code. Here's why: The images are added first. In the image adding section, you're running this line of code: $_FILES = array("moreimages" => $image); Then when you get to your routine that adds the files, you start with this: $files = $_FILES['morefiles']; Can you see what's wrong here? At ...


1

WordPress's authentication system is made up of pluggable functions, which means that you can write a plugin that has a function named, say, wp_authenticate(), and your site will use your wp_authenticate() function instead of the native WordPress one. Your comment about is_user_logged_in() (on your original post) is obviated by the fact that ...


1

You might start by looking at the is_user_logged_in() pluggable function. https://developer.wordpress.org/reference/functions/is_user_logged_in/ This is basically two lines: $user = wp_get_current_user(); return $user->exists(); In your case, wrap the links inside the curly braces of a conditional. if ( is_user_logged_in() ) { // link }


1

You can try this function: wp_localize_script( $handle, $name, $data ); See https://codex.wordpress.org/Function_Reference/wp_localize_script for documentation. As the codex says: Though localization is the primary use, it can be used to make any data available to your script that you can normally only get from the server side of WordPress. I had to ...


1

Figured it out after thinking it through.. if (stripos(strtolower($template_filename), 'home') !== false) { $results[] = $template_name; }


1

If you want to concatenate function result into a string you should be returning it, not echoing it. Echo just sends it to output. Also you are making a typical mistake of confusing two flavor of WP template tags. Convention is the following: the_* template tags echo result immediately; get_the_* template tags return result. Internally former is usually ...


1

Is using Auth0 (http://www.auth0.com) maybe an option for you? They have a very good Wordpress plugin. I think you could integrate your system and do a Single Sign On (SSO) using the plugin. I think it's a better option for you to do some stuff on your system to integrate (since you know the system and can probably be more productive), using this ...



Only top voted, non community-wiki answers of a minimum length are eligible