0

I needed to have dynamic URLs created once a user (say Organization) submitted a registration form where the URL would be domain.com/organizations/organization-name/dashboard/

The "organization-name" is part of the registration form that gets checked by Ajax for duplication. (this is already accomplished )

The problem I have is that the URL is getting created in root not within the theme. So I'm getting a blank screen.

My question is, how can I extend my current theme to these dynamic URLs that get created. How do I place my current theme's header/footer within this code:

function arfGenURL($orgName)
{
date_default_timezone_set('America/New_York');
$dir = "organizations/" . $orgName . "/dashboard/";
echo var_dump(mkdir($dir,0777,TRUE));
$content = "<html><head><title>Organization Dashboard |</title></head><body></body></html>";
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . '/' . $dir . "/index.php","wb");
fwrite($fp,$content);
fclose($fp);
print_r(error_get_last());
}

Thank you!

1
  • in the code above, what can I put in $content that pull header and footer of active theme? ...any ideas folks?
    – Dave_O
    Commented May 9, 2015 at 16:11

1 Answer 1

0

There isn't much "dynamic" about actually creating folder tree and index files in it. What you have right now is completely tangential to your WordPress installation.

In a nutshell, if you need to integrate this with WordPress, you have two approaches:

  1. Load WordPress core in your code. This can be done with including wp-load.php and some fine–tuning, but it's pretty advanced technique (done properly).

  2. Load your code in WordPress. This will involve getting it in line with WP mechanics and likely using Rewrite API to deal with links.

Either is quite involved really. Keeping standalone functionality separate might actually be quite practical, if you are not willing to spent time on adapting it properly.

5
  • Hey Rarst, thanks for your thoughts. Can you suggest any other way of creating the dynamic URL as described if I decide not to go this rout that I'm at?
    – Dave_O
    Commented May 10, 2015 at 5:28
  • How do you mean by "standalone"?
    – Dave_O
    Commented May 10, 2015 at 5:43
  • I mean that in current state your code doesn't seem to use any of WP functionality. It pretty much does things in a way that goes against WP functionality (time zone stuff, writing files...).
    – Rarst
    Commented May 10, 2015 at 9:02
  • If I were to have this load to Wordpress, how do you suggest to get it going? I had a programmer to do this for me but obviously WP was not considered. I want learn the mechanics, so any direction will greatly be appreciated.
    – Dave_O
    Commented May 10, 2015 at 17:18
  • As per answer — different approaches to this. Maybe through loading core, maybe through rewrite, maybe something different altogether. Creating custom URLs in WP is far from friendly...
    – Rarst
    Commented May 10, 2015 at 18:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.