Function like is_registration_page to check if current page is registration page

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?

Topic wp-signup signup user-registration Wordpress

Category Web


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


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;
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.