Site logo

[Support request] Hooks and variables

Home Forums Support [Support request] Hooks and variables

Home Forums Support Hooks and variables

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2474501
    Raul

    Hello

    I want to use some PHP code to a. restrict access to posts and b. create a navigation menu for the non-restricted posts.
    My code is tested and works fine but I thought to use hooks for that.

    I would like to use some variables from the main code/hook that restricts pages according to some things in the second code/hook that shows the links for the non-restricted pages (…before_right_sidebar_content).
    I have tried, but it seems that the variables from one hook are not seen in the other hook.

    I’m relatively beginner to WordPress and don’t know if these variables are supposed to be seen from one hook to another as globals, or so.
    Is any solution to this that you can indicate to me, or should I look for a developer?

    Thank you.

    #2475049
    Ying
    Staff
    Customer Support

    Hi Raul,

    Unfortunately, we cannot help with your custom code as it’s beyond the scope of the support forum.

    GP’s hooks are to insert HTML or PHP that outputs HTML, it does not affect the code itself.

    #2475438
    Raul

    I wouldn’t ask for a custom code. In fact, my code is working fine using the GP hooks.

    What I ask is if it’s possible to pass a PHP variable from one hook to another within the same post. Details are in my initial post.

    #2475459
    Fernando
    Customer Support

    Hi Raul,

    Depending on what you’re trying to do, one way to use a variable on a different hook is by making the variable a Global Variable.

    See: https://wordpress.stackexchange.com/questions/89263/how-to-set-and-use-global-variables-or-why-not-to-use-them-at-all#:~:text=optimisation%2C%20not%20faster!-,How%20To%20Use%20Globals,-When%20you%20try

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.