Jump to content

hook for admin addonmodule


jimlongo

Recommended Posts

I'm trying to write a hook that will either display a success message or a form depending on some php logic.

So far I have a hook, that in real simple terms is like this

add_hook('AdminAreaPage', 1, function ($vars){
	$extraVariables = [];
	$are_we_connected = true;  // sparing you our custom code, but this could be false
	if ($are_we_connected) {
		$extraVariables['isConnected'] = true;
	}else{
		$extraVariables['isConnected'] = false;
	}
    return $extraVariables;
});

Then in the template file I have 

{if $isConnected}
show the success message
{else}
show the form
{/if}

Seems to me this should display the success message, but it continues to show the form.

 

If I do something like this the page displays the correct message,

{if 1==1}
show the success message
{else}
the form
{/if}

so I'm assuming i'm not using the $extraVariables[] properly.

 

Any hints would be appreciated, TIA.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated