-
AuthorPosts
-
June 1, 2021 at 9:11 am #1303361
I’m running the latest versions of WordPress and ENFOLD on my site. The site is a marketing tool to sell a product.
Multiple people will use the site to promote to their teams, so I want to give them a URL that will pass in a session variable, that contains a ‘user.’ Something like this:
http://domian.name/?user=falconThen there is a link on the site, that would need to populate with the ‘user’ data, so the correct registration (manual) link is generated. Like so:
https://falcon.otherdomain.name/site/
I want to populate ENFOLD theme menu, settings, with php data. Can I do that?What’s a simple way to do this?
- This topic was modified 3 years, 5 months ago by stupaul22. Reason: typo
June 2, 2021 at 2:49 pm #1303606Hey stupaul22,
Thank you for the inquiry.
Are you trying to create a membership site or hide/display content exclusively? Unfortunately, this is not available in the theme out of the box, and adding this feature will require significant amount of modification, which is beyond the scope of support.
You might be able to use a plugin WP Membership or Simple Membership to restrict the visibility of a certain page or content.
Best regards,
IsmaelJune 4, 2021 at 5:22 pm #1304114I decided to go the cookie route with this and I wrote the following code, and placed it in functions.php. The code:
1) uses if(isset($_GET[‘user’])) to look for three GET variables that were passed in the URL, like so:
http://helium-hotspot.net/?usr=falcon&phn=720-745-1760& (Email address hidden if logged out)
2) If the Get variable isset, then the those values are set as a cookie with setcookie.
3) Else if the GET variables are empty the it sets cookies using default values.
4) lastly it creates a shortcode to place in wordpress.Everything works, but the problem is the function runs on every page and if the values arer NOT again passed on that page the default values get placed.
What I want is to set the variables one time and carry them through the website as the user navigates. Even better , have the same variables in place the next time the user visits..I understand that php wipes everything and starts fresh every time a page is loaded.What logic could I add to accomplish this?
May be what I am trying to do is more suited for placing the values in the user meta table in the database.
If GET
// SET COOKIE function set_usr_cookie() { // Get usr from URL $affiliate_user = $_GET['usr']; if(isset($_GET['usr'])) { // Set the cookie setcookie('afuser', $affiliate_user , time()+31556926); } else{ setcookie('afuser', 'falcon' , time()+31556926); } function affil_user() { // Use information stored in the cookie $current_afuser = $_COOKIE['afuser']; $string .= $current_afuser ; return $string; } // Add a shortcode add_shortcode('insert_user', 'affil_user'); } add_action('init', 'set_usr_cookie'); function set_phn_cookie() { // Get phn from URL $affiliate_phone = $_GET['phn']; if(isset($_GET['phn'])) { // Set the cookie setcookie('afphone', $affiliate_phone , time()+31556926); } else{ setcookie('afphone', '720-275-1350' , time()+31556926); } function affil_phone() { // Use information stored in the cookie $current_afphone = $_COOKIE['afphone']; $string .= $current_afphone ; return $string; } // Add a shortcode add_shortcode('insert_phone', 'affil_phone'); } add_action('init', 'set_phn_cookie'); function set_eml_cookie() { // Get eml from URL $affiliate_email = $_GET['eml']; if(isset($_GET['eml'])) { // Set the cookie setcookie('afemail', $affiliate_email , time()+31556926); } else{ setcookie('afemail', ' (Email address hidden if logged out) ' , time()+31556926); } function affil_email() { // Use information stored in the cookie $current_afemail = $_COOKIE['afemail']; $string .= $current_afemail ; return $string; } // Add a shortcode add_shortcode('insert_email', 'affil_email'); } add_action('init', 'set_eml_cookie');
June 4, 2021 at 5:28 pm #1304116Bottom line is:
What’s the best way to do this:
Multiple people will use the site to promote to their teams, so I want to give them a URL that will pass in a session variable, that contains a ‘user.’ Something like this:
http://domian.name/?user=falconThen there is a link on the site, that would need to populate with the ‘user’ data, so the correct registration (manual) link is generated. Like so:
https://falcon.otherdomain.name/site/
I want to populate ENFOLD theme menu, settings, with php data. Can I do that?June 7, 2021 at 4:24 pm #1304436Hi,
Everything works, but the problem is the function runs on every page and if the values arer NOT again passed on that page the default values get placed.
Have you tried using the is_page conditional function so that the function only runs on the specified pages?
// https://developer.wordpress.org/reference/functions/is_page/
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.