Jump to content

Recommended Posts

I got the following code. I need to insert a "get_footer();" tag, but the code won't run. How do I code insert it properly?

 

				$random_password = wp_generate_password( 12, false );
			$status = wp_create_user( $username, $random_password, $email );
			if ( is_wp_error($status) ) 
				echo "Username already exists. Please try another one.";
---------------------------------INSERT get_footer(); HERE.-------------------------------------------
			else {
				$from = get_option('admin_email');
				$headers = 'From: '.$from . "\r\n";
				$subject = "Registration successful";
				$msg = "Registration successful.\nYour login details\nUsername: $username\nPassword: $random_password";
				wp_mail( $email, $subject, $msg, $headers );

				echo "Please check your email for login details.";
				get_footer();
			}

Link to comment
https://forums.phpfreaks.com/topic/249191-proper-coding-grammar/
Share on other sites

				if ( is_wp_error($status) ) {
				   echo "Username already exists. Please try another one.";
                                           get_footer();
                                        }

get_footer() statement is in multiple place in that code, and it works fine.

When I try to put get_footer() under echo "Usern ... her one." line - it gives me an error.

 

and yes, this is for wordpress

 

I need get_footer() to run under first condition, and it okay under second condition.

MasterACE's solution will work.  My suggestion is that you don't need to run get_footer() in every different senerio on the page.  Rather, run it at the bottom of the page, as it is served no matter what.  If there is ever a function that you must include in every if/else statement, putting it below all of the statements will get the same effect, but with less code.

My suggestion is that you don't need to run get_footer() in every different senerio on the page.  Rather, run it at the bottom of the page, as it is served no matter what.  If there is ever a function that you must include in every if/else statement, putting it below all of the statements will get the same effect, but with less code.

that is a far better solution. Rather than the 'quick fix'.

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.