2

You can use is_admin to check to see if the current web page is part of WordPress' administrator interface.

Is there a way to see if the page being processed is the registration page?

3
  • 3
    Are you asking about this page: wp-login.php?action=register or is there a custom registration page you're referring to. – signal2013 Dec 7 '17 at 19:00
  • That sounds right to me, although I've noticed that $GLOBAS["pagenow"] is index.php on the registration page. Maybe I'm wrong. – Flimm Dec 7 '17 at 19:04
  • Here's an answer I posted a while back that may help. It demonstrates how to detect if the visitor is on the Registration, Password reset, or Log in page and then how to wire up filters. Specifically, I'm thinking the conditional statements used to detect what wp-login.php variant is being used might be helpful. – Dave Romsey Dec 7 '17 at 21:45
3

You could create your own simple function.

function is_registration_page() {
    if ( $GLOBALS['pagenow'] == 'wp-login.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'register' ) {
        return true;
    }
    return false;
}
1

How about attempting to intercept the registration page via hooks. Here's an example of how hooks can be used to add a field to the registration form (below)... Depending on your situation, you can use this (and the hook to intercept a submitted form) as a means to achieve what you're looking for.

I added in a line: $GLOBALS['is_registration'] = TRUE;

But note, this global variable may not be available at the point you require it. You will have to test to see.

<?php
add_action( 'register_form', 'myplugin_add_registration_fields' );
function myplugin_add_registration_fields() {

    $GLOBALS['is_registration'] = TRUE;

    //Get and set any values already sent
    $user_extra = ( isset( $_POST['user_extra'] ) ) ? $_POST['user_extra'] : '';
?>
    <label for="user_extra"><?php _e( 'Extra Field', 'myplugin_textdomain' ) ?>
    <input type="text" name="user_extra" id="user_extra" class="input" value="<?php echo esc_attr( stripslashes( $user_extra ) ); ?>" size="25" /></label>
<?php
}
?>

You can read more about these action/filter hooks at: https://codex.wordpress.org/Plugin_API/Action_Reference/register_form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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