The MU forums have moved to WordPress.org

insert wp_x_capabilities not possible (4 posts)

  1. nicoa
    Member
    Posted 17 years ago #

    hi all,

    i'm desperating on a problem updating the capabilities within a plugin.

    i make a hook on user_register and try to insert the capabilities in the usermeta-table.

    $cap_key = $wpmuBaseTablePrefix . $blog_id . '_capabilities';

    update_usermeta( $userid, $cap_key, $cap );

    but this doesn't work. i can insert wp__capabilities, wp1_capabilities, wp_1capabilities but there is no way to insert the correct key wp_1_capabilities.

    if i make a sql-query this way:

    $wpdb->query( "INSERT INTO " . $wpdb->usermeta .
     "(umeta_id,user_id,meta_key,meta_value)
    VALUES ( NULL, '$userid', '" .
    $wpmuBaseTablePrefix . $blog_id . "_capabilities',
     'a:1:{s:" . strlen( $role ) . ":"" .
    $role."";b:1;}')" );

    it doesn't work also. but if i feed mysql with the statement everything works as expecteted...

    any ideas?

    thanks a lot,
    nico

  2. nicoa
    Member
    Posted 17 years ago #

    ok...
    - wp_T_capabilities works also
    - wp_5_capabilities works as well
    but
    - wp_1_capabilities doesn't work...

    that's a little bit frustrating ;)

  3. nicoa
    Member
    Posted 17 years ago #

    ok... it get's deletet...

  4. nicoa
    Member
    Posted 17 years ago #

    finally found the solution...

    in wpmu-functions.php in function wpmu_create_user they get deleted:

    update_user_option($user_id, 'capabilities', '');
    update_user_option($user_id, 'user_level', '');

    two lines down i found the line

    do_action( 'wpmu_new_user', $user_id );

    after a big pot of cereals i noticed that wpmu_new_user isn't the same as user_register...

    so... espresso isn't as useful as cereals ;)

About this Topic