WordPress.org

Make WordPress Core

Ticket #15819: user_can_for_blog.patch

File user_can_for_blog.patch, 1.2 KB (added by mweichert, 7 years ago)

Add user_can_for_blog function to capabilities.php

  • /Users/mweichert/Downloads/capabilities

    # This patch file was generated by NetBeans IDE
    # This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
    # It uses platform neutral UTF-8 encoding.
    # Above lines and this line are ignored by the patching process.
    old new  
    11101110}
    11111111
    11121112/**
     1113 * Whether a particular user has a capability or role for a given blog
     1114 *
     1115 * @since 3.1.1
     1116 *
     1117 * @param int $user User ID or WP_User object
     1118 * @param int $blog_id Blog ID
     1119 * @param string $capability Capability or role name
     1120 * @return bool
     1121 */
     1122function user_can_for_blog( $user, $blog_id, $capability) {
     1123    if ( ! is_object( $user ) )
     1124        $user = new WP_User( $user );
     1125
     1126    if ( ! $user || ! $user->ID )
     1127        return false;
     1128
     1129    // Set the blog id.  @todo add blog id arg to WP_User constructor?
     1130    $user->for_blog( $blog_id );
     1131
     1132    $args = array_slice( func_get_args(), 3 );
     1133    die(print_r($args));
     1134    $args = array_merge( array( $capability ), $args );
     1135
     1136    return call_user_func_array( array( &$user, 'has_cap' ), $args );
     1137}
     1138
     1139/**
    11131140 * Retrieve role object.
    11141141 *
    11151142 * @see WP_Roles::get_role() Uses method to retrieve role object.