Any PHP-Cracks around for little help? (2 posts)

  1. stereopoly
    Posted 6 years ago #

    Hey guys, I'm not that pro in coding PHP. It surely seems easy to you but not to me :-)

    My idea: When having the custom field "member_content" show a little message and the login/register-forms. It almost works but the forms are now shown in all articles because I don't know how to connect all this PHP-stuff.

    Please help!

    <?php if(!get_post_meta($post->ID, 'member_content', true) || is_user_logged_in()) {
      					    the_content('<p>Read the rest of this entry ยป</p>');
      					} else {
      					    global $more;	// Declare global $more (before the loop).
      					    $more = 0;	// Set (inside the loop) to display content above the more tag.
      					    the_content(""); //pass empty string to avoid showing "more" link
      					    echo '<p>Um den gesamten Artikel lesen zu k&ouml;nnen, musst du eingeloggt sein. The complete article is only available to members. Please log in to read the article in its 	entirely.</p>';
      					}; ?>
      					<?php if(!get_post_meta($post->ID, 'member_content', true) || is_user_logged_in()) { ?>
      						<div id="single-forms">
      						<div class="login-form-single"><form class="clearfix" action="<?php echo wp_login_url(get_permalink()); ?>" method="post">
      							<h3>Zutritt zur mitStil Lounge</h3>
      							<label class="grey" for="log">Benutzername:</label>
      							<input class="field" type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="23" />
      							<label class="grey" for="pwd">Passwort:</label>
      							<input class="field" type="password" name="pwd" id="pwd" size="23" /><br />
      							<label><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Passwort Merken</label>
      							<div class="clear"></div>
      							<input type="submit" name="submit" value="Login" class="bt_login" />
      							<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
      							<a class="lost-pwd" href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Passwort vergessen?</a>
      					<?php } ?>
      					<?php if(!get_post_meta($post->ID, 'member_content', true) ||get_option('users_can_register')) : ?>
      									<!-- Register Form -->
      									<div class="register-form-single">
      									<form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
      										<h3>Registrier&apos; dich jetzt!</h3>
      										<label class="grey" for="user_login"><?php _e('Username') ?></label>
      										<input class="field" type="text" name="user_login" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="20" tabindex="10" />
      										<label class="grey" for="user_email"><?php _e('E-mail') ?></label>
      										<input class="field" type="text" name="user_email" id="user_email" class="input" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="25" tabindex="20" />
      										<?php do_action('register_form'); ?>
      										<label id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></label>
      										<input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Register'); ?>" class="bt_register" />
      									</form></div></div><br class="clear" />
      								<?php else : ?>
      									<h1>Registration is closed</h1>
      									<p>Sorry, you are not allowed to register by yourself on this site!</p>
      									<p>You must either be invited by one of our team member or request an invitation by email at <b>info {at} yoursite {dot} com</b>.</p>
      									<!-- Admin, delete text below later when you are done with configuring this panel -->
      									<p style="border-top:1px solid #333;border-bottom:1px solid #333;padding:10px 0;margin-top:10px;color:white"><em>Note: If you are the admin and want to display the register form here, log in to your dashboard, and go to <b>Settings</b> > <b>General</b> and click "Anyone can register".</em></p></div><br class="clear" />
      								<?php endif ?>
  2. stereopoly
    Posted 6 years ago #

    One more update: Of course I would love to show the forms only if the user is not already logged in... Hope you can help me! Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic