adjust custom plugin to userroles instead of users

  • Unknown's avatar

    I am using a tournament bracket software that automatically gives someone there own bracket once they are logged in.

    I have this custom plugin written that can give users more than 1 bracket, however I want to make it so it applies to user roles not users. Below is the code that gives all users 2 brackets. I want to change it so it gives 2 brackets to only the user role called “silver”. 3 brackets to the userrole called “gold”, and 4 to “platinum”. Any help is appreciated. The blog is down now, but I am using the bracketpress plugin.

    CODE FOLLOWS:

    add_action( ‘wp_login’, ‘my_bracketpress_add_brackets’, 10, 2 );

    function my_bracketpress_add_brackets($username, $user) {

    $num_brackets = 2;

    // Get the brackets for this user
    $query = new WP_Query(array(‘post_type’ => ‘brackets’, “author” => $user->ID) );

    // Add a new bracket up to the limit defined in num brackets
    for ($i = $query->post_count; $i < $num_brackets; $i++) {
    $title = ‘Bracket For ‘ . $username
    bracketpress()->create_bracket_post($user->ID, $title, true)

    }

    }

  • Unknown's avatar

    You are in the wrong forum and need to be at WordPress.ORG for help with that version of the software.

  • Unknown's avatar
  • The topic ‘adjust custom plugin to userroles instead of users’ is closed to new replies.