0

Just starting to use WP for the first time as I am working on integrating a standalone app I've been working on into an existing wp site. The goal is to have the app remain functionally seperate from the site except that users of the app will be associated with a user on the wp site.

As such, I need a simple script that I can call on a link/button on the wp site which will get the current user's id, and then redirect the user to the application with a copy of the id in the request.

I'm not really having so much trouble writing this sort of script, its only a few lines, but I am having trouble understanding where in the WP file structure it should go and how to actually call it from the wp page. Is this something that requires writing an entire custom plugin? I don't really know how this all works.

1 Answer 1

1

Custom code inside of a custom plugin is the right way to do this in wordpress. Creating "an entire custom plugin" is not a lot of effort.

  1. Via FTP go to wp-content >> plugins

  2. Inside of this folder create a new folder called cebo or whatever you like

  3. Inside of this newly created folder, create a php file with the same name as the folder like cebo.php

  4. So that wordpress will recognize it as a plugin, put the following code at the top of the php file

    /*

    Plugin Name: Cebo Plugin

    Description: Description of what the plugin does

    Author: Cebo

    Version: 1.0

    */

After that you paste your code that you want to run in wordpress.

As the folder and the file is in the plugin folder of your wordpress installation (wp-content -> plugins), wordpress will now list it in the plugins section in the backend.

Activate the plugin to run your code.

Sign up to request clarification or add additional context in comments.

3 Comments

Okay, I've gotten in showing up. How do I now call that script? Just ajax to its file path on a button press or something?
Calling the function by its name in a template file, if you want to output some results there. Or you can make it run everywhere on init of wordpress developer.wordpress.org/reference/hooks/init
As I said in my original post, I want a button which will call the script. But based on what youre saying, should I just use the scripts file path in the href field of the button? I know wp has some single-point-of-entry stuff for ajax, does it have something similar for normal script calls? Some sort of special url format I should use or something like that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.