Jump to content
Sign in to follow this  
dhtemple

PlatformPro/PHP questions

Recommended Posts

dhtemple

1) What is the secret to being able to call wp_get_current_user (and access other global wp functions) from a pagelines_loop_post_end (for example) hook? I'm using functions.php in platformbase and assumed if I included require_once('wp-includes/pluggable.php'); that might make the functions available to no avail. 2) IF I want to set a slug for a page and have it be called with essentially no content (except headers and footers) and want wordpress' default page-slug.php functionality how does that work with platformPro? Or does platformPro basically override the possibility to use the page-slug.php mechanism? Thanks!

Share this post


Link to post
Share on other sites
cmunns

You should be able to just use this sort of thing in your functions.php file ` wp_get_current_user(); /** * @example Safe usage: $current_user = wp_get_current_user(); * if ( !($current_user instanceof WP_User) ) * return; */ echo 'Username: ' . $current_user->user_login . '

'; echo 'User email: ' . $current_user->user_email . '

'; echo 'User first name: ' . $current_user->user_firstname . '

'; echo 'User last name: ' . $current_user->user_lastname . '

'; echo 'User display name: ' . $current_user->display_name . '

'; echo 'User ID: ' . $current_user->ID . '

'; ` What are you trying to do with item 2 above? I don't think you would ever have to use this bc the options are built-in

Share this post


Link to post
Share on other sites
dhtemple

Thanks Adam, I don't know what I was doing with the current_user stuff but that works fine. Regarding #2...I'm creating custom pages that will contain a form or a report or some other db i/o functionality. It seems there are a few ways to do this and I want to make sure I'm using the best (most compatible) way. Here are some ways I've gotten this to work: --- A) Create a page using the Default template. Hide the content area and other stuff I don't want so I basically end up with just header and footer. Then use a GET var when calling this page to trigger functions.php to add an action/hook that then displays a form and calls another URL that works similarly to save the data and display the results. ie:

	if ($_GET['mode'] == 'test') {
	  add_action('pagelines_after_maincontent', '__my_first_hook');
	  add_action('pagelines_after_maincontent', '__my_second_hook', 10, 5);
	}
	
This works but I end up using a template that I am forced to hide stuff on. I essentially can re-use this page with different GET vars to trigger any particular form or db i/o I desire so it works and is flexible. --- B) Creating page.test.php in platformbase then creating a page that uses this custom test template. Essentially using the same GET var mechanism to trigger functionality as needed. ie:
	<?php
	/*
		Template Name: Test Page
	*/
	
	get_header();
	
	// my code goes here based on GET vars
	echo 'hi - this is from page.test.php';
	
	get_footer();
	

--- B works (or should, I haven't tested it full-circle yet) but forces all my db i/o pages to go through one funnel. If I were able to use the page.slug.php method I could create the pages and based on slug name they would call directly to their own specific file without my intervention. 6 of one half-dozen of the other probably in the big scheme of things I suppose. So, is there a better way than A or B to manage a page with header/footer and custom code in the content area? Thoughts? Thanks for your help as I slowly grok all that this stuff does :-)

Share this post


Link to post
Share on other sites
Kate

Hi Dana, Personally I would use option B. That's what the custom templates are there for ;)

Share this post


Link to post
Share on other sites
dhtemple

Thanks Kate - anyone else care to chime in on if method B is "best practice" for this type of thing? Thanks!

Share this post


Link to post
Share on other sites
camaleo

I am also following method B, the only addition is that you need to add a series of <div> to keep the look consistent: ` get_header(); ?>

<?php echo '$_POST'; var_dump($_POST);echo '
'; echo '$_GET'; var_dump($_GET);echo '
'; $_INPUT['blogname'] = $_POST['blogname']; ?>
<?php get_footer(); ` then there maybe to investigate the css to position things the way you like, but its not a big issue I guess.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×