lundi 13 juin 2016

"Fatal error: Call to a member function get_text() on null" in wordpress

I'm using plugin wp-members for wordpress and I need to modify login form, and after I enter the array into a function i get this error "Fatal error: Call to a member function get_text() on null"

this is my code in functions.php

add_filter( 'wpmem_login_form', 'my_login_form_filter' );

function my_login_form_filter( $form, $action = 'login' )
 {
      /**
     * The login form is brought in with $form
     * You can append to it or filter it
     *
     * $action specifies the form being constructed. It
     * can be: login|pwdreset|pwdchange
     */

$form = array(
    array(
        'name'   => $wpmem->get_text( "login_username" ), 
        'type'   => 'text', 
        'tag'    => 'log',
        'class'  => 'username',
        'div'    => 'div_text',
    ),
    array( 
        'name'   => $wpmem->get_text( "login_password" ), 
        'type'   => 'password', 
        'tag'    => 'pwd', 
        'class'  => 'password',
        'div'    => 'div_text',
    ),
    array(
        'name'   => $wpmem->get_text( "login_number" ), 
        'type'   => 'text', 
        'tag'    => 'log', 
        'class'  => 'username',
        'div'    => 'div_text',)
);

return $form;
}

And this is the section of the code of the plugin in question

if ( ! function_exists( 'wpmem_inc_login' ) ):
            /**
             * Login Dialog.
             *
             * Loads the login form for user login.
             *
             * @since 1.8
             *
             * @global object $wpmem        The WP_Members object.
             * @global string $wpmem_regchk The WP-Members message   container.
             * @global object $post         The WordPress Post object.
             *
             * @param  string $page
             * @param  string $redirect_to
             * @return string $str         The generated html for the login form.
             */
            function wpmem_inc_login( $page = "page", $redirect_to = null, $show = 'show' ) {

                global $wpmem, $wpmem_regchk, $post;

                $str = '';

                if ( $page == "page" ) {

                     if ( $wpmem_regchk != "success" ) {

                        $dialogs = get_option( 'wpmembers_dialogs' );

                        // This shown above blocked content.
                        $msg = $wpmem->get_text( 'restricted_msg' );
                        $msg = ( $dialogs['restricted_msg'] == $msg ) ? $msg : __( stripslashes( $dialogs['restricted_msg'] ), 'wp-members' );
                        $str = "<p>$msg</p>";

                        /**
                         * Filter the post restricted message.
                         *
                         * @since 2.7.3
                         *
                         * @param string $str The post restricted message.
                         */
                        $str = apply_filters( 'wpmem_restricted_msg', $str );

                    }   
                } 

                // Create the default inputs.
                $default_inputs = array(
                    array(
                        'name'   => $wpmem->get_text( 'login_username' ), 
                        'type'   => 'text', 
                        'tag'    => 'log',
                        'class'  => 'username',
                        'div'    => 'div_text',
                    ),
                    array( 
                        'name'   => $wpmem->get_text( 'login_password' ), 
                        'type'   => 'password', 
                        'tag'    => 'pwd', 
                        'class'  => 'password',
                        'div'    => 'div_text',
                    ),
                );

                /**
                 * Filter the array of login form fields.
                 *
                 * @since 2.9.0
                 *
                 * @param array $default_inputs An array matching the                      elements used by default.
                 */
                $default_inputs = apply_filters( 'wpmem_inc_login_inputs', $default_inputs );

                $defaults = array( 
                    'heading'      => $wpmem->get_text( 'login_heading' ), 
                    'action'       => 'login', 
                    'button_text'  => $wpmem->get_text( 'login_button' ),
                    'inputs'       => $default_inputs,
                    'redirect_to'  => $redirect_to,
                );  

                /**
                 * Filter the arguments to override login form defaults.
                 *
                 * @since 2.9.0
                 *
                 * @param array $args An array of arguments to use. Default null.
                 */
                $args = apply_filters( 'wpmem_inc_login_args', '' );

                $arr  = wp_parse_args( $args, $defaults );

                $str  = ( $show == 'show' ) ? $str . wpmem_login_form( $page, $arr ) : $str;

                return $str;
            }
            endif;



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire