• Hi,
    I would like to add a new function – write a log comment in an external text file – to the existing registration function of my WP installation.
    I imagine that I have to implement a hook (what is the format that, I suppose, I have to include in functions.php), I appreciate your help.
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Opariti

    (@opariti)

    I have implemented the following and included in the twentyforteen’s (the active theme) functions.php file:

    if ( ! function_exists( 'register_for_cmsa' ) ) :
    	function register_for_cmsa($user_id)	{
    	// write in an external file
            // writeLogWP($msg) is a function from an included file in index.php
            writeLogWP("A new user is: " . $user_id);
    	}
    	add_action('user_register', 'register_for_cmsa');
    endif;

    But, the code is not accepted (page blank) when running WP under wp-admin section when I try to add a new user. The user is added but the page doesn’t return to the users list and I get nothing in the file where it is intended to write.
    I have tested the writeLogWP($msg) as a statement elsewhere inside the same functions.php file and the file is written when I go through the site side of WP (not the admn one).

    Thread Starter Opariti

    (@opariti)

    The solution, for anyone having the same issue is related to the fact that IN ADMIN OPERATIONS the file index.php is not accessed. Therefore, all initializations done there MUST BE REDONE next to the place we use them. In my case it was to include the file with the writeLogWP($msg) function in the functions.php itself

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Alter the wordpress registration function’ is closed to new replies.