简体   繁体   中英

modify register form in buddypress

I have a theme called wplms, used for learning management system.

I need to allow instructors of courses to register in website directly as instructors (not students) and I need too that the administrator don't have to moderate each instructor's registration.

For it, I've modified core of bp-members/bp-members-classes.php

In line 314, I have commented the line:

$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_status = 2 WHERE ID = %d", $user_id ) );

because I want activate the user (instructor) just registered

And in lines 319 and 320 I've commented:

delete_user_option( $user_id, ‘capabilities’ );
delete_user_option( $user_id, ‘user_level’ );

because these lines are overwritting the wp_capalities that I previously defined.

But I want to do this without modify the core. Could you give me a better way? Thanks very much.

NOTE: I've noticed that the user registered appears in wp admin > users as instructors as well…but too as pendings…

There is one hook when the method add_backcompat() returns its results. With it you could reverse what $wpdb->query and delete_user_option have done.

You have to find out what you need to fill the function:

<?php
/**
 * Plugin Name: (BP) Instructors registration adjustment
 */

add_filter( 'bp_core_signups_add_backcompat', 'bp_so_24199347' );

function bp_so_24199347( $user_id ) {
    // $wpdb->query( REVERT );
    // add_user_option( REVERT );

    return $user_id;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM