• I recently discovered that this plugin does not allow a user to change the multiple passwords if the option to prevent password duplication is activated. I have this option activated as I need different passwords for different pages in a given hierarchy.

    I have changed the following code:

    if( $bawmpp_options['clone_pass']!='on' ){
    	$ids = implode( ',', $a_ids );
    	$wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->posts . ' SET post_password = %s WHERE ID in ( ' . $ids . ' )', $_POST['post_password'] ) );
    	$multiple_passwords = array_filter( array_map( 'trim', explode( "\n", $_POST['multiple_passwords'] ) ) );
    	foreach( $a_ids as $post_id )
    		update_post_meta( $post_id, '_morepasswords', $multiple_passwords );
    }

    to the following, which allow the modification of passwords regardless of the password duplication option:

    if( $bawmpp_options['clone_pass']!='on' ){
    	$ids = implode( ',', $a_ids );
    	$wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->posts . ' SET post_password = %s WHERE ID in ( ' . $ids . ' )', $_POST['post_password'] ) );
    	$multiple_passwords = array_filter( array_map( 'trim', explode( "\n", $_POST['multiple_passwords'] ) ) );
    	foreach( $a_ids as $post_id )
    		update_post_meta( $post_id, '_morepasswords', $multiple_passwords );
    } else {
    	$wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->posts . ' SET post_password = %s WHERE ID = ' . (int) $_POST['post_ID'], $_POST['post_password'] ) );
    	$multiple_passwords = array_filter( array_map( 'trim', explode( "\n", $_POST['multiple_passwords'] ) ) );
    	update_post_meta( (int) $_POST['post_ID'], '_morepasswords', $multiple_passwords );
    }

    The modifications were made in the file backend-noajax.inc.php, inside the inc directory, starting at line 153 (inside the bawmpp_update_password function).

    This solved my problem entirely but I think the changes (or some similar update to the code) should be put in the trunk and a new version published so that people with the password duplication prevention option activated can change their passwords.

    http://wordpress.org/plugins/baw-multiple-pass-for-protected-pages/

  • The topic ‘Changes to code to allow multiple password change’ is closed to new replies.