protected static function formProfile() {

		check_admin_referer( 'pb-user-catalog' );

		$user_id = isset( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0;

		if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
			wp_die( __( 'You do not have permission to do that.', 'pressbooks' ) );
		}

		// Set Redirect URL
		if ( get_current_user_id() !== $user_id ) {
			$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog&user_id=' . $user_id );
		} else {
			$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog' );
		}

		/* Go! */

		$catalog = new static( $user_id );
		$catalog->saveProfile( $_POST );
		$catalog->uploadLogo( 'pb_catalog_logo' );

		$catalog->deleteCache();

		// Ok!
		$_SESSION['pb_notices'][] = __( 'Settings saved.' );

		// Redirect back to form
		\Pressbooks\Redirect\location( $redirect_url );
	}
protected static function formProfile() {

		check_admin_referer( 'pb-user-catalog' );

		$user_id = isset( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0;

		if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
			wp_die( __( 'You do not have permission to do that.', 'pressbooks' ) );
		}

		// Set Redirect URL
		if ( get_current_user_id() !== $user_id ) {
			$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog&user_id=' . $user_id );
		} else {
			$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog' );
		}

		/* Go! */

		$catalog = new static( $user_id );
		$catalog->saveProfile( $_POST );
		$catalog->uploadLogo( 'pb_catalog_logo' );

		$catalog->deleteCache();

		// Ok!
		$_SESSION['pb_notices'][] = __( 'Settings saved.' );

		// Redirect back to form
		\Pressbooks\Redirect\location( $redirect_url );
	}
protected static function formProfile ( ) { check_admin_referer ( 'pb-user-catalog' ) ; $ user_id = isset ( $ _REQUEST [ 'user_id' ] ) ? absint ( $ _REQUEST [ 'user_id' ] ) : 0 ; if ( empty ( $ user_id ) || ! current_user_can ( 'edit_user' , $ user_id ) ) { wp_die ( __ ( 'You do not have permission to do that.' , 'pressbooks' ) ) ; } // Set Redirect URL if ( get_current_user_id ( ) !== $ user_id ) { $ redirect_url = get_admin_url ( get_current_blog_id ( ) , '/index.php?page=pb_catalog&user_id=' . $ user_id ) ; } else { $ redirect_url = get_admin_url ( get_current_blog_id ( ) , '/index.php?page=pb_catalog' ) ; } /* Go! */ $ catalog = new static ( $ user_id ) ; $ catalog -> saveProfile ( $ _POST ) ; $ catalog -> uploadLogo ( 'pb_catalog_logo' ) ; $ catalog -> deleteCache ( ) ; // Ok! $ _SESSION [ 'pb_notices' ] [ ] = __ ( 'Settings saved.' ) ; // Redirect back to form \ Pressbooks \ Redirect \ location ( $ redirect_url ) ; }
Save catalog profile to database
Save catalog profile to database